mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
Fixed spells not rendering on non-pony entities
This commit is contained in:
parent
39672e5028
commit
34aa3b8ced
4 changed files with 49 additions and 41 deletions
|
@ -6,6 +6,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.client.FirstPersonRendererOverrides.ArmRenderer;
|
import com.minelittlepony.unicopia.client.FirstPersonRendererOverrides.ArmRenderer;
|
||||||
|
import com.minelittlepony.unicopia.client.minelittlepony.MineLPDelegate;
|
||||||
import com.minelittlepony.unicopia.client.render.spell.SpellEffectsRenderDispatcher;
|
import com.minelittlepony.unicopia.client.render.spell.SpellEffectsRenderDispatcher;
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
@ -13,14 +14,14 @@ import net.minecraft.client.model.ModelPart;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.util.Arm;
|
import net.minecraft.util.Arm;
|
||||||
|
|
||||||
public class AccessoryFeatureRenderer<
|
public class AccessoryFeatureRenderer<
|
||||||
T extends LivingEntity,
|
T extends LivingEntity,
|
||||||
M extends BipedEntityModel<T>> extends FeatureRenderer<T, M> {
|
M extends EntityModel<T>> extends FeatureRenderer<T, M> {
|
||||||
|
|
||||||
private static final List<FeatureFactory<?>> REGISTRY = new ArrayList<>();
|
private static final List<FeatureFactory<?>> REGISTRY = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -40,6 +41,10 @@ public class AccessoryFeatureRenderer<
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
|
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
|
||||||
|
if (MineLPDelegate.getInstance().getRace(entity).isEquine()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
features.forEach(feature -> feature.render(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch));
|
features.forEach(feature -> feature.render(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch));
|
||||||
|
|
||||||
Caster.of(entity).ifPresent(caster -> {
|
Caster.of(entity).ifPresent(caster -> {
|
||||||
|
@ -60,7 +65,7 @@ public class AccessoryFeatureRenderer<
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface FeatureFactory<T extends LivingEntity> {
|
public interface FeatureFactory<T extends LivingEntity> {
|
||||||
Feature<T> create(FeatureRendererContext<T, ? extends BipedEntityModel<T>> context);
|
Feature<T> create(FeatureRendererContext<T, ? extends EntityModel<T>> context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Feature<T extends LivingEntity> {
|
public interface Feature<T extends LivingEntity> {
|
||||||
|
@ -75,11 +80,11 @@ public class AccessoryFeatureRenderer<
|
||||||
|
|
||||||
public interface FeatureRoot<
|
public interface FeatureRoot<
|
||||||
T extends LivingEntity,
|
T extends LivingEntity,
|
||||||
M extends BipedEntityModel<T>> {
|
M extends EntityModel<T>> {
|
||||||
AccessoryFeatureRenderer<T, M> getAccessories();
|
AccessoryFeatureRenderer<T, M> getAccessories();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Nullable
|
@Nullable
|
||||||
static <T extends LivingEntity, M extends BipedEntityModel<T>> FeatureRoot<T, M> of(T entity) {
|
static <T extends LivingEntity, M extends EntityModel<T>> FeatureRoot<T, M> of(T entity) {
|
||||||
var renderer = MinecraftClient.getInstance().getEntityRenderDispatcher().getRenderer(entity);
|
var renderer = MinecraftClient.getInstance().getEntityRenderDispatcher().getRenderer(entity);
|
||||||
if (renderer instanceof FeatureRoot) {
|
if (renderer instanceof FeatureRoot) {
|
||||||
return (FeatureRoot<T, M>)renderer;
|
return (FeatureRoot<T, M>)renderer;
|
||||||
|
|
|
@ -1,19 +1,9 @@
|
||||||
package com.minelittlepony.unicopia.mixin.client;
|
package com.minelittlepony.unicopia.mixin.client;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.client.render.AccessoryFeatureRenderer;
|
|
||||||
|
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
|
||||||
import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer;
|
import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer;
|
||||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
|
||||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
import net.minecraft.client.render.model.BakedModelManager;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
|
||||||
@Mixin(ArmorFeatureRenderer.class)
|
@Mixin(ArmorFeatureRenderer.class)
|
||||||
|
@ -21,13 +11,13 @@ abstract class MixinArmorFeatureRenderer<
|
||||||
T extends LivingEntity,
|
T extends LivingEntity,
|
||||||
M extends BipedEntityModel<T>,
|
M extends BipedEntityModel<T>,
|
||||||
A extends BipedEntityModel<T>>
|
A extends BipedEntityModel<T>>
|
||||||
extends FeatureRenderer<T, M> implements AccessoryFeatureRenderer.FeatureRoot<T, M> {
|
extends FeatureRenderer<T, M>/* implements AccessoryFeatureRenderer.FeatureRoot<T, M>*/ {
|
||||||
|
|
||||||
private AccessoryFeatureRenderer<T, M> accessories;
|
//private AccessoryFeatureRenderer<T, M> accessories;
|
||||||
|
|
||||||
MixinArmorFeatureRenderer() { super(null); }
|
MixinArmorFeatureRenderer() { super(null); }
|
||||||
|
|
||||||
@Override
|
/*@Override
|
||||||
public AccessoryFeatureRenderer<T, M> getAccessories() {
|
public AccessoryFeatureRenderer<T, M> getAccessories() {
|
||||||
return accessories;
|
return accessories;
|
||||||
}
|
}
|
||||||
|
@ -40,5 +30,5 @@ abstract class MixinArmorFeatureRenderer<
|
||||||
@Inject(method = "render", at = @At("RETURN"))
|
@Inject(method = "render", at = @At("RETURN"))
|
||||||
private void onRender(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch, CallbackInfo info) {
|
private void onRender(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, T entity, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch, CallbackInfo info) {
|
||||||
getAccessories().render(stack, renderContext, lightUv, entity, limbDistance, limbAngle, tickDelta, age, headYaw, headPitch);
|
getAccessories().render(stack, renderContext, lightUv, entity, limbDistance, limbAngle, tickDelta, age, headYaw, headPitch);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,25 @@
|
||||||
package com.minelittlepony.unicopia.mixin.client;
|
package com.minelittlepony.unicopia.mixin.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.At.Shift;
|
import org.spongepowered.asm.mixin.injection.At.Shift;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.client.render.AccessoryFeatureRenderer;
|
||||||
import com.minelittlepony.unicopia.client.render.AnimalPoser;
|
import com.minelittlepony.unicopia.client.render.AnimalPoser;
|
||||||
import com.minelittlepony.unicopia.client.render.PlayerPoser;
|
import com.minelittlepony.unicopia.client.render.PlayerPoser;
|
||||||
|
import com.minelittlepony.unicopia.client.render.AccessoryFeatureRenderer.FeatureRoot;
|
||||||
|
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
import net.minecraft.client.render.entity.EntityRenderer;
|
import net.minecraft.client.render.entity.EntityRenderer;
|
||||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||||
|
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
import net.minecraft.client.render.entity.model.EntityModel;
|
import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
|
@ -21,8 +29,31 @@ import net.minecraft.entity.mob.MobEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
@Mixin(LivingEntityRenderer.class)
|
@Mixin(LivingEntityRenderer.class)
|
||||||
abstract class MixinLivingEntityRenderer<T extends LivingEntity, M extends EntityModel<T>> extends EntityRenderer<T> implements FeatureRendererContext<T, M> {
|
abstract class MixinLivingEntityRenderer<T extends LivingEntity, M extends EntityModel<T>> extends EntityRenderer<T>
|
||||||
|
implements FeatureRendererContext<T, M>, FeatureRoot<T, M> {
|
||||||
|
@Shadow
|
||||||
|
private @Final List<FeatureRenderer<T, M>> features;
|
||||||
|
|
||||||
MixinLivingEntityRenderer() { super(null); }
|
MixinLivingEntityRenderer() { super(null); }
|
||||||
|
@Nullable
|
||||||
|
private AccessoryFeatureRenderer<T, M> accessories;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public AccessoryFeatureRenderer<T, M> getAccessories() {
|
||||||
|
if (accessories == null) {
|
||||||
|
accessories = features.stream()
|
||||||
|
.filter(a -> a instanceof FeatureRoot)
|
||||||
|
.map(a -> ((FeatureRoot<T, M>)a).getAccessories())
|
||||||
|
.findFirst()
|
||||||
|
.orElseGet(() -> {
|
||||||
|
var feature = new AccessoryFeatureRenderer<>(this);
|
||||||
|
features.add(feature);
|
||||||
|
return feature;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return accessories;
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "render",
|
@Inject(method = "render",
|
||||||
at = @At(
|
at = @At(
|
||||||
|
@ -36,6 +67,7 @@ abstract class MixinLivingEntityRenderer<T extends LivingEntity, M extends Entit
|
||||||
VertexConsumerProvider vertices,
|
VertexConsumerProvider vertices,
|
||||||
int light,
|
int light,
|
||||||
CallbackInfo into) {
|
CallbackInfo into) {
|
||||||
|
getAccessories();
|
||||||
if (entity instanceof PlayerEntity player) {
|
if (entity instanceof PlayerEntity player) {
|
||||||
PlayerPoser.INSTANCE.applyPosing(matrices, player, (BipedEntityModel<?>)getModel(), PlayerPoser.Context.THIRD_PERSON);
|
PlayerPoser.INSTANCE.applyPosing(matrices, player, (BipedEntityModel<?>)getModel(), PlayerPoser.Context.THIRD_PERSON);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package com.minelittlepony.unicopia.mixin.client;
|
package com.minelittlepony.unicopia.mixin.client;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.At.Shift;
|
import org.spongepowered.asm.mixin.injection.At.Shift;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.client.render.AccessoryFeatureRenderer;
|
|
||||||
import com.minelittlepony.unicopia.client.render.PlayerPoser;
|
import com.minelittlepony.unicopia.client.render.PlayerPoser;
|
||||||
import com.minelittlepony.unicopia.client.render.AccessoryFeatureRenderer.FeatureRoot;
|
import com.minelittlepony.unicopia.client.render.AccessoryFeatureRenderer.FeatureRoot;
|
||||||
|
|
||||||
|
@ -21,31 +19,14 @@ import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.util.Arm;
|
import net.minecraft.util.Arm;
|
||||||
|
|
||||||
@Mixin(PlayerEntityRenderer.class)
|
@Mixin(PlayerEntityRenderer.class)
|
||||||
abstract class MixinPlayerEntityRenderer
|
abstract class MixinPlayerEntityRenderer extends LivingEntityRenderer<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> {
|
||||||
extends LivingEntityRenderer<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>>
|
|
||||||
implements FeatureRoot<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> {
|
|
||||||
@Nullable
|
|
||||||
private AccessoryFeatureRenderer<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> accessories;
|
|
||||||
|
|
||||||
MixinPlayerEntityRenderer() { super(null, null, 0); }
|
MixinPlayerEntityRenderer() { super(null, null, 0); }
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public AccessoryFeatureRenderer<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> getAccessories() {
|
|
||||||
if (accessories == null) {
|
|
||||||
accessories = features.stream()
|
|
||||||
.filter(a -> a instanceof FeatureRoot)
|
|
||||||
.map(a -> ((FeatureRoot<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>>)a).getAccessories())
|
|
||||||
.findFirst()
|
|
||||||
.orElseGet(() -> new AccessoryFeatureRenderer<>(this));
|
|
||||||
}
|
|
||||||
return accessories;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "renderArm", at = @At("RETURN"))
|
@Inject(method = "renderArm", at = @At("RETURN"))
|
||||||
private void onRenderArm(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, AbstractClientPlayerEntity player, ModelPart arm, ModelPart sleeve, CallbackInfo info) {
|
private void onRenderArm(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, AbstractClientPlayerEntity player, ModelPart arm, ModelPart sleeve, CallbackInfo info) {
|
||||||
Arm a = this.getModel().leftArm == arm ? Arm.LEFT : Arm.RIGHT;
|
Arm a = this.getModel().leftArm == arm ? Arm.LEFT : Arm.RIGHT;
|
||||||
getAccessories().renderArm(matrices, vertexConsumers, light, player, arm, a);
|
((FeatureRoot<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>>)this).getAccessories().renderArm(matrices, vertexConsumers, light, player, arm, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "renderArm",
|
@Inject(method = "renderArm",
|
||||||
|
|
Loading…
Reference in a new issue