mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 04:27:59 +01:00
Refactor pony renderers for mobs a little
This commit is contained in:
parent
a5ba1951ef
commit
0f02895da2
15 changed files with 275 additions and 412 deletions
|
@ -25,33 +25,33 @@ public final class MobRenderers {
|
|||
});
|
||||
public static final MobRenderers ILLAGER = register("illagers", (state, pony) -> {
|
||||
pony.switchRenderer(state, EntityType.VEX, VexRenderer::new);
|
||||
pony.switchRenderer(state, EntityType.EVOKER, IllagerPonyRenderer.Evoker::new);
|
||||
pony.switchRenderer(state, EntityType.VINDICATOR, IllagerPonyRenderer.Vindicator::new);
|
||||
pony.switchRenderer(state, EntityType.EVOKER, IllagerPonyRenderer::evoker);
|
||||
pony.switchRenderer(state, EntityType.VINDICATOR, IllagerPonyRenderer::vindicator);
|
||||
pony.switchRenderer(state, EntityType.ILLUSIONER, IllagerPonyRenderer.Illusionist::new);
|
||||
pony.switchRenderer(state, EntityType.PILLAGER, PillagerRenderer::new);
|
||||
});
|
||||
public static final MobRenderers ZOMBIE = register("zombies", (state, pony) -> {
|
||||
pony.switchRenderer(state, EntityType.ZOMBIE, ZomponyRenderer::new);
|
||||
pony.switchRenderer(state, EntityType.HUSK, ZomponyRenderer.Husk::new);
|
||||
pony.switchRenderer(state, EntityType.GIANT, ZomponyRenderer.Giant::new);
|
||||
pony.switchRenderer(state, EntityType.DROWNED, ZomponyRenderer.Drowned::new);
|
||||
pony.switchRenderer(state, EntityType.ZOMBIE, ZomponyRenderer::zombie);
|
||||
pony.switchRenderer(state, EntityType.HUSK, ZomponyRenderer::husk);
|
||||
pony.switchRenderer(state, EntityType.GIANT, ZomponyRenderer::giant);
|
||||
pony.switchRenderer(state, EntityType.DROWNED, ZomponyRenderer::drowned);
|
||||
});
|
||||
public static final MobRenderers PIGLIN = register("pigzombies", (state, pony) -> {
|
||||
pony.switchRenderer(state, EntityType.PIGLIN, PonyPiglinRenderer::new);
|
||||
pony.switchRenderer(state, EntityType.PIGLIN_BRUTE, PonyPiglinRenderer::new);
|
||||
pony.switchRenderer(state, EntityType.ZOMBIFIED_PIGLIN, PonyPiglinRenderer::new);
|
||||
pony.switchRenderer(state, EntityType.PIGLIN, PonyPiglinRenderer::piglin);
|
||||
pony.switchRenderer(state, EntityType.PIGLIN_BRUTE, PonyPiglinRenderer::brute);
|
||||
pony.switchRenderer(state, EntityType.ZOMBIFIED_PIGLIN, PonyPiglinRenderer::zombified);
|
||||
if (!MineLittlePony.getInstance().getConfig().noFun.get()) {
|
||||
pony.switchRenderer(state, EntityType.PIG, PonyPigRenderer::new);
|
||||
}
|
||||
});
|
||||
public static final MobRenderers SKELETON = register("skeletons", (state, pony) -> {
|
||||
pony.switchRenderer(state, EntityType.SKELETON, SkeleponyRenderer::new);
|
||||
pony.switchRenderer(state, EntityType.STRAY, SkeleponyRenderer.Stray::new);
|
||||
pony.switchRenderer(state, EntityType.WITHER_SKELETON, SkeleponyRenderer.Wither::new);
|
||||
pony.switchRenderer(state, EntityType.SKELETON, SkeleponyRenderer::skeleton);
|
||||
pony.switchRenderer(state, EntityType.STRAY, SkeleponyRenderer::stray);
|
||||
pony.switchRenderer(state, EntityType.WITHER_SKELETON, SkeleponyRenderer::wither);
|
||||
});
|
||||
public static final MobRenderers GUARDIAN = register("guardians", (state, pony) -> {
|
||||
pony.switchRenderer(state, EntityType.GUARDIAN, SeaponyRenderer::new);
|
||||
pony.switchRenderer(state, EntityType.ELDER_GUARDIAN, SeaponyRenderer.Elder::new);
|
||||
pony.switchRenderer(state, EntityType.GUARDIAN, SeaponyRenderer::guardian);
|
||||
pony.switchRenderer(state, EntityType.ELDER_GUARDIAN, SeaponyRenderer::elder);
|
||||
});
|
||||
public static final MobRenderers ENDERMAN = register("endermen", (state, pony) -> {
|
||||
pony.switchRenderer(state, EntityType.ENDERMAN, EnderStallionRenderer::new);
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
package com.minelittlepony.client.render.entity;
|
||||
|
||||
import com.minelittlepony.api.pony.IPony;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.client.model.*;
|
||||
import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
|
||||
import com.minelittlepony.client.render.IPonyRenderContext;
|
||||
import com.minelittlepony.client.render.EquineRenderManager;
|
||||
import com.minelittlepony.client.render.entity.feature.*;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
import com.minelittlepony.mson.api.ModelKey;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.Frustum;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.render.entity.MobEntityRenderer;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.render.entity.model.PlayerEntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public abstract class AbstractPonyRenderer<T extends MobEntity, M extends EntityModel<T> & IPonyModel<T>> extends MobEntityRenderer<T, M> implements IPonyRenderContext<T, M> {
|
||||
|
||||
protected final EquineRenderManager<T, M> manager = new EquineRenderManager<>(this);
|
||||
|
||||
private final Map<Wearable, Identifier> wearableTextures = new EnumMap<>(Wearable.class);
|
||||
|
||||
private final TextureSupplier<T> texture;
|
||||
|
||||
private final float scale;
|
||||
|
||||
public AbstractPonyRenderer(EntityRendererFactory.Context context, ModelKey<? super M> key, TextureSupplier<T> texture, float scale) {
|
||||
super(context, null, 0.5F);
|
||||
this.model = manager.setModel(key).body();
|
||||
this.texture = texture;
|
||||
this.scale = scale;
|
||||
addFeatures(context);
|
||||
}
|
||||
|
||||
protected void addFeatures(EntityRendererFactory.Context context) {
|
||||
addFeature(new ArmourFeature<>(this, context.getModelManager()));
|
||||
addFeature(createHeldItemFeature(context));
|
||||
addFeature(new SkullFeature<>(this, context.getModelLoader()));
|
||||
addFeature(new ElytraFeature<>(this));
|
||||
addFeature(new GearFeature<>(this));
|
||||
}
|
||||
|
||||
protected HeldItemFeature<T, M> createHeldItemFeature(EntityRendererFactory.Context context) {
|
||||
return new GlowingItemFeature<>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Identifier getTexture(T entity) {
|
||||
return texture.apply(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(T entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {
|
||||
super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv);
|
||||
DebugBoundingBoxRenderer.render(manager.getPony(entity), this, entity, stack, renderContext, tickDelta);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupTransforms(T entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
|
||||
manager.preRenderCallback(entity, stack, partialTicks);
|
||||
if (getModel() instanceof PlayerEntityModel) {
|
||||
((PlayerEntityModel<?>)getModel()).setVisible(true);
|
||||
}
|
||||
|
||||
if (getModel().getAttributes().isSitting) {
|
||||
stack.translate(0, 0.125D, 0);
|
||||
}
|
||||
|
||||
rotationYaw = manager.getRenderYaw(entity, rotationYaw, partialTicks);
|
||||
super.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
||||
|
||||
manager.applyPostureTransform(entity, stack, rotationYaw, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(T entity, Frustum visibleRegion, double camX, double camY, double camZ) {
|
||||
return super.shouldRender(entity, manager.getFrustrum(entity, visibleRegion), camX, camY, camZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scale(T entity, MatrixStack stack, float tickDelta) {
|
||||
shadowRadius = manager.getShadowScale();
|
||||
|
||||
if (entity.isBaby()) {
|
||||
shadowRadius *= 3; // undo vanilla shadow scaling
|
||||
}
|
||||
|
||||
if (!entity.hasVehicle()) {
|
||||
stack.translate(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow
|
||||
} else {
|
||||
stack.translate(0, entity.getHeightOffset(), 0);
|
||||
}
|
||||
|
||||
stack.scale(scale, scale, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelWrapper<T, M> getModelWrapper() {
|
||||
return manager.playerModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabelIfPresent(T entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) {
|
||||
stack.push();
|
||||
stack.translate(0, manager.getNamePlateYOffset(entity), 0);
|
||||
super.renderLabelIfPresent(entity, name, stack, renderContext, maxDistance);
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getDefaultTexture(T entity, Wearable wearable) {
|
||||
return wearableTextures.computeIfAbsent(wearable, w -> {
|
||||
Identifier texture = getTexture(entity);
|
||||
texture = new Identifier(texture.getNamespace(), texture.getPath().split("\\.")[0] + "_" + wearable.name().toLowerCase(Locale.ROOT) + ".png");
|
||||
|
||||
if (MinecraftClient.getInstance().getResourceManager().getResource(texture).isPresent()) {
|
||||
return texture;
|
||||
}
|
||||
return wearable.getDefaultTexture();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public EquineRenderManager<T, M> getInternalRenderer() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getEntityPony(T entity) {
|
||||
return IPony.getManager().getPony(getTexture(entity));
|
||||
}
|
||||
|
||||
public static <E extends MobEntity, M extends ClientPonyModel<E>, T extends PonyRenderer<E, M>, F extends FeatureRenderer<E, M>>
|
||||
T appendFeature(T renderer, Function<T, F> featureFactory) {
|
||||
renderer.addFeature(featureFactory.apply(renderer));
|
||||
return renderer;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static <T extends MobEntity, M extends EntityModel<T> & IPonyModel<T>> AbstractPonyRenderer<T, M> proxy(EntityRendererFactory.Context context, ModelKey<? super M> key, TextureSupplier<T> texture, float scale,
|
||||
List exportedLayers, Consumer<M> modelConsumer) {
|
||||
var renderer = new AbstractPonyRenderer<T, M>(context, key, texture, scale) {
|
||||
@Override
|
||||
protected void addFeatures(EntityRendererFactory.Context context) {
|
||||
features.clear();
|
||||
super.addFeatures(context);
|
||||
}
|
||||
};
|
||||
exportedLayers.clear();
|
||||
exportedLayers.addAll(renderer.features);
|
||||
modelConsumer.accept(renderer.getModel());
|
||||
return renderer;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.minelittlepony.client.model.ModelType;
|
|||
import com.minelittlepony.client.model.entity.EnderStallionModel;
|
||||
import com.minelittlepony.client.render.entity.feature.GlowingEyesFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
import com.minelittlepony.client.render.entity.feature.GlowingItemFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.GlowingEyesFeature.IGlowingRenderer;
|
||||
|
||||
|
@ -26,18 +27,18 @@ public class EnderStallionRenderer extends PonyRenderer<EndermanEntity, EnderSta
|
|||
private final Random rnd = new Random();
|
||||
|
||||
public EnderStallionRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.ENDERMAN);
|
||||
super(context, ModelType.ENDERMAN, TextureSupplier.of(ENDERMAN));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addLayers(EntityRendererFactory.Context context) {
|
||||
addFeature(createItemHoldingLayer());
|
||||
protected void addFeatures(EntityRendererFactory.Context context) {
|
||||
addFeature(createHeldItemFeature(context));
|
||||
addFeature(new StuckArrowsFeatureRenderer<>(context, this));
|
||||
addFeature(new GlowingEyesFeature<>(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HeldItemFeature<EndermanEntity, EnderStallionModel> createItemHoldingLayer() {
|
||||
protected HeldItemFeature<EndermanEntity, EnderStallionModel> createHeldItemFeature(EntityRendererFactory.Context context) {
|
||||
return new GlowingItemFeature<EndermanEntity, EnderStallionModel>(this) {
|
||||
@Override
|
||||
protected ItemStack getRightItem(EndermanEntity entity) {
|
||||
|
@ -51,17 +52,10 @@ public class EnderStallionRenderer extends PonyRenderer<EndermanEntity, EnderSta
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(EndermanEntity entity) {
|
||||
return ENDERMAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(EndermanEntity entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {
|
||||
EnderStallionModel modelenderman = getModel();
|
||||
|
||||
modelenderman.isCarrying = entity.getCarriedBlock() != null;
|
||||
modelenderman.isAttacking = entity.isAngry();
|
||||
model.isCarrying = entity.getCarriedBlock() != null;
|
||||
model.isAttacking = entity.isAngry();
|
||||
|
||||
if (entity.isAngry()) {
|
||||
stack.translate(rnd.nextGaussian() / 50, 0, rnd.nextGaussian() / 50);
|
||||
|
|
|
@ -58,7 +58,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements IPonyRen
|
|||
|| feature instanceof ElytraFeatureRenderer
|
||||
|| feature instanceof ShoulderParrotFeatureRenderer;
|
||||
});
|
||||
addLayer(new ArmourFeature<>(this));
|
||||
addLayer(new ArmourFeature<>(this, context.getModelManager()));
|
||||
addLayer(new GlowingItemFeature<>(this));
|
||||
addLayer(new DJPon3Feature<>(this));
|
||||
addLayer(new CapeFeature<>(this));
|
||||
|
|
|
@ -1,42 +1,33 @@
|
|||
package com.minelittlepony.client.render.entity;
|
||||
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.mob.AbstractPiglinEntity;
|
||||
import net.minecraft.entity.mob.HostileEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.PiglinPonyModel;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
public class PonyPiglinRenderer extends PonyRenderer<HostileEntity, PiglinPonyModel> {
|
||||
private static final Identifier PIGLIN = new Identifier("minelittlepony", "textures/entity/piglin/piglin_pony.png");
|
||||
private static final Identifier PIGLIN_BRUTE = new Identifier("minelittlepony", "textures/entity/piglin/piglin_brute_pony.png");
|
||||
private static final Identifier ZOMBIFIED_PIGLIN = new Identifier("minelittlepony", "textures/entity/piglin/zombified_piglin_pony.png");
|
||||
|
||||
public class PonyPiglinRenderer extends PonyRenderer.Caster<HostileEntity, PiglinPonyModel> {
|
||||
|
||||
private static final Map<EntityType<?>, Identifier> TEXTURES = Util.make(new HashMap<>(), map -> {
|
||||
map.put(EntityType.PIGLIN, new Identifier("minelittlepony", "textures/entity/piglin/piglin_pony.png"));
|
||||
map.put(EntityType.PIGLIN_BRUTE, new Identifier("minelittlepony", "textures/entity/piglin/piglin_brute_pony.png"));
|
||||
map.put(EntityType.ZOMBIFIED_PIGLIN, new Identifier("minelittlepony", "textures/entity/piglin/zombified_piglin_pony.png"));
|
||||
});
|
||||
|
||||
public PonyPiglinRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.PIGLIN);
|
||||
public PonyPiglinRenderer(EntityRendererFactory.Context context, Identifier texture, float scale) {
|
||||
super(context, ModelType.PIGLIN, TextureSupplier.of(texture), scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scale(HostileEntity entity, MatrixStack stack, float ticks) {
|
||||
super.scale(entity, stack, ticks);
|
||||
if (entity.getType() == EntityType.PIGLIN_BRUTE) {
|
||||
stack.scale(1.15F, 1.15F, 1.15F);
|
||||
}
|
||||
public static PonyPiglinRenderer piglin(EntityRendererFactory.Context context) {
|
||||
return new PonyPiglinRenderer(context, PIGLIN, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(HostileEntity entity) {
|
||||
return TEXTURES.get(entity.getType());
|
||||
public static PonyPiglinRenderer brute(EntityRendererFactory.Context context) {
|
||||
return new PonyPiglinRenderer(context, PIGLIN_BRUTE, 1.15F);
|
||||
}
|
||||
|
||||
public static PonyPiglinRenderer zombified(EntityRendererFactory.Context context) {
|
||||
return new PonyPiglinRenderer(context, ZOMBIFIED_PIGLIN, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,162 +1,26 @@
|
|||
package com.minelittlepony.client.render.entity;
|
||||
|
||||
import com.minelittlepony.api.pony.IPony;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.model.IPonyModel;
|
||||
import com.minelittlepony.client.model.ModelWrapper;
|
||||
import com.minelittlepony.client.render.DebugBoundingBoxRenderer;
|
||||
import com.minelittlepony.client.render.IPonyRenderContext;
|
||||
import com.minelittlepony.client.render.EquineRenderManager;
|
||||
import com.minelittlepony.client.render.entity.feature.GearFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.GlowingItemFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.ArmourFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.SkullFeature;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
import com.minelittlepony.mson.api.ModelKey;
|
||||
import com.minelittlepony.client.render.entity.feature.ElytraFeature;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.Frustum;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.render.entity.MobEntityRenderer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.render.entity.model.PlayerEntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.render.entity.feature.StuckArrowsFeatureRenderer;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public abstract class PonyRenderer<T extends MobEntity, M extends EntityModel<T> & IPonyModel<T>> extends MobEntityRenderer<T, M> implements IPonyRenderContext<T, M> {
|
||||
public class PonyRenderer<T extends MobEntity, M extends ClientPonyModel<T>> extends AbstractPonyRenderer<T, M> {
|
||||
|
||||
protected final EquineRenderManager<T, M> manager = new EquineRenderManager<>(this);
|
||||
|
||||
private final Map<Wearable, Identifier> wearableTextures = new EnumMap<>(Wearable.class);
|
||||
|
||||
public PonyRenderer(EntityRendererFactory.Context context, ModelKey<? super M> key) {
|
||||
super(context, null, 0.5F);
|
||||
this.model = manager.setModel(key).body();
|
||||
addLayers(context);
|
||||
public PonyRenderer(EntityRendererFactory.Context context, ModelKey<? super M> key, TextureSupplier<T> texture) {
|
||||
this(context, key, texture, 1);
|
||||
}
|
||||
|
||||
protected void addLayers(EntityRendererFactory.Context context) {
|
||||
addFeature(new ArmourFeature<>(this));
|
||||
addFeature(createItemHoldingLayer());
|
||||
//addFeature(new StuckArrowsFeatureRenderer<>(this));
|
||||
addFeature(new SkullFeature<>(this, context.getModelLoader()));
|
||||
addFeature(new ElytraFeature<>(this));
|
||||
addFeature(new GearFeature<>(this));
|
||||
}
|
||||
|
||||
protected abstract HeldItemFeature<T, M> createItemHoldingLayer();
|
||||
|
||||
@Override
|
||||
public void render(T entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {
|
||||
super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv);
|
||||
DebugBoundingBoxRenderer.render(manager.getPony(entity), this, entity, stack, renderContext, tickDelta);
|
||||
public PonyRenderer(EntityRendererFactory.Context context, ModelKey<? super M> key, TextureSupplier<T> texture, float scale) {
|
||||
super(context, key, texture, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupTransforms(T entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
|
||||
manager.preRenderCallback(entity, stack, partialTicks);
|
||||
if (getModel() instanceof PlayerEntityModel) {
|
||||
((PlayerEntityModel<?>)getModel()).setVisible(true);
|
||||
}
|
||||
|
||||
if (getModel().getAttributes().isSitting) {
|
||||
stack.translate(0, 0.125D, 0);
|
||||
}
|
||||
|
||||
rotationYaw = manager.getRenderYaw(entity, rotationYaw, partialTicks);
|
||||
super.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
||||
|
||||
manager.applyPostureTransform(entity, stack, rotationYaw, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(T entity, Frustum visibleRegion, double camX, double camY, double camZ) {
|
||||
return super.shouldRender(entity, manager.getFrustrum(entity, visibleRegion), camX, camY, camZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scale(T entity, MatrixStack stack, float tickDelta) {
|
||||
shadowRadius = manager.getShadowScale();
|
||||
|
||||
if (entity.isBaby()) {
|
||||
shadowRadius *= 3; // undo vanilla shadow scaling
|
||||
}
|
||||
|
||||
if (!entity.hasVehicle()) {
|
||||
stack.translate(0, 0, -entity.getWidth() / 2); // move us to the center of the shadow
|
||||
} else {
|
||||
stack.translate(0, entity.getHeightOffset(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelWrapper<T, M> getModelWrapper() {
|
||||
return manager.playerModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabelIfPresent(T entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) {
|
||||
stack.push();
|
||||
stack.translate(0, manager.getNamePlateYOffset(entity), 0);
|
||||
super.renderLabelIfPresent(entity, name, stack, renderContext, maxDistance);
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getDefaultTexture(T entity, Wearable wearable) {
|
||||
return wearableTextures.computeIfAbsent(wearable, w -> {
|
||||
Identifier texture = getTexture(entity);
|
||||
texture = new Identifier(texture.getNamespace(), texture.getPath().split("\\.")[0] + "_" + wearable.name().toLowerCase(Locale.ROOT) + ".png");
|
||||
|
||||
if (MinecraftClient.getInstance().getResourceManager().getResource(texture).isPresent()) {
|
||||
return texture;
|
||||
}
|
||||
return wearable.getDefaultTexture();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public EquineRenderManager<T, M> getInternalRenderer() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPony getEntityPony(T entity) {
|
||||
return IPony.getManager().getPony(getTexture(entity));
|
||||
}
|
||||
|
||||
public abstract static class Caster<T extends MobEntity, M extends ClientPonyModel<T>> extends PonyRenderer<T, M> {
|
||||
|
||||
public Caster(EntityRendererFactory.Context context, ModelKey<? super M> key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HeldItemFeature<T, M> createItemHoldingLayer() {
|
||||
return new GlowingItemFeature<>(this);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class Proxy<T extends MobEntity, M extends EntityModel<T> & IPonyModel<T>> extends PonyRenderer<T, M> {
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public Proxy(List exportedLayers, EntityRendererFactory.Context context, ModelKey<? super M> key) {
|
||||
super(context, key);
|
||||
|
||||
exportedLayers.addAll(features);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addLayers(EntityRendererFactory.Context context) {
|
||||
features.clear();
|
||||
super.addLayers(context);
|
||||
}
|
||||
protected void addFeatures(EntityRendererFactory.Context context) {
|
||||
super.addFeatures(context);
|
||||
addFeature(new StuckArrowsFeatureRenderer<>(context, this));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import com.minelittlepony.client.mixin.IResizeable;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.GuardianPonyModel;
|
||||
import com.minelittlepony.client.render.entity.PonyRenderer.Proxy;
|
||||
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.GlowingItemFeature;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
|
@ -21,24 +19,19 @@ import net.minecraft.util.Identifier;
|
|||
public class SeaponyRenderer extends GuardianEntityRenderer {
|
||||
public static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/entity/seapony.png");
|
||||
|
||||
private final Proxy<GuardianEntity, GuardianPonyModel> ponyRenderer;
|
||||
private final AbstractPonyRenderer<GuardianEntity, GuardianPonyModel> ponyRenderer;
|
||||
|
||||
public SeaponyRenderer(EntityRendererFactory.Context context) {
|
||||
public SeaponyRenderer(EntityRendererFactory.Context context, float scale) {
|
||||
super(context);
|
||||
ponyRenderer = AbstractPonyRenderer.proxy(context, ModelType.GUARDIAN, TextureSupplier.of(TEXTURE), scale, features, m -> model = m);
|
||||
}
|
||||
|
||||
features.clear();
|
||||
ponyRenderer = new Proxy<GuardianEntity, GuardianPonyModel>(features, context, ModelType.GUARDIAN) {
|
||||
@Override
|
||||
public Identifier getTexture(GuardianEntity entity) {
|
||||
return TEXTURE;
|
||||
}
|
||||
public static SeaponyRenderer guardian(EntityRendererFactory.Context context) {
|
||||
return new SeaponyRenderer(context, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HeldItemFeature<GuardianEntity, GuardianPonyModel> createItemHoldingLayer() {
|
||||
return new GlowingItemFeature<>(this);
|
||||
}
|
||||
};
|
||||
model = ponyRenderer.getModel();
|
||||
public static SeaponyRenderer elder(EntityRendererFactory.Context context) {
|
||||
return new SeaponyRenderer(context, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,17 +57,4 @@ public class SeaponyRenderer extends GuardianEntityRenderer {
|
|||
|
||||
resize.setCurrentSize(origin);
|
||||
}
|
||||
|
||||
public static class Elder extends SeaponyRenderer {
|
||||
|
||||
public Elder(EntityRendererFactory.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void scale(GuardianEntity entity, MatrixStack stack, float ticks) {
|
||||
super.scale(entity, stack, ticks);
|
||||
stack.scale(2.35F, 2.35F, 2.35F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,11 @@ package com.minelittlepony.client.render.entity;
|
|||
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.SkeleponyModel;
|
||||
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.GlowingItemFeature;
|
||||
import com.minelittlepony.client.render.entity.feature.StrayClothingFeature;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.mob.AbstractSkeletonEntity;
|
||||
import net.minecraft.entity.mob.StrayEntity;
|
||||
import net.minecraft.entity.mob.WitherSkeletonEntity;
|
||||
import net.minecraft.entity.mob.*;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class SkeleponyRenderer<Skeleton extends AbstractSkeletonEntity> extends PonyRenderer<Skeleton, SkeleponyModel<Skeleton>> {
|
||||
|
@ -19,50 +15,19 @@ public class SkeleponyRenderer<Skeleton extends AbstractSkeletonEntity> extends
|
|||
public static final Identifier WITHER = new Identifier("minelittlepony", "textures/entity/skeleton/skeleton_wither_pony.png");
|
||||
public static final Identifier STRAY = new Identifier("minelittlepony", "textures/entity/skeleton/stray_pony.png");
|
||||
|
||||
public SkeleponyRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.SKELETON);
|
||||
public SkeleponyRenderer(EntityRendererFactory.Context context, Identifier texture, float scale) {
|
||||
super(context, ModelType.SKELETON, TextureSupplier.of(texture), scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(Skeleton entity) {
|
||||
return SKELETON;
|
||||
public static SkeleponyRenderer<SkeletonEntity> skeleton(EntityRendererFactory.Context context) {
|
||||
return new SkeleponyRenderer<>(context, SKELETON, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HeldItemFeature<Skeleton, SkeleponyModel<Skeleton>> createItemHoldingLayer() {
|
||||
return new GlowingItemFeature<>(this);
|
||||
public static SkeleponyRenderer<StrayEntity> stray(EntityRendererFactory.Context context) {
|
||||
return PonyRenderer.appendFeature(new SkeleponyRenderer<>(context, STRAY, 1), StrayClothingFeature::new);
|
||||
}
|
||||
|
||||
public static class Stray extends SkeleponyRenderer<StrayEntity> {
|
||||
|
||||
public Stray(EntityRendererFactory.Context context) {
|
||||
super(context);
|
||||
addFeature(new StrayClothingFeature<>(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(StrayEntity entity) {
|
||||
return STRAY;
|
||||
}
|
||||
public static SkeleponyRenderer<WitherSkeletonEntity> wither(EntityRendererFactory.Context context) {
|
||||
return new SkeleponyRenderer<>(context, WITHER, 1.2F);
|
||||
}
|
||||
|
||||
public static class Wither extends SkeleponyRenderer<WitherSkeletonEntity> {
|
||||
|
||||
public Wither(EntityRendererFactory.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(WitherSkeletonEntity entity) {
|
||||
return WITHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scale(WitherSkeletonEntity skeleton, MatrixStack stack, float ticks) {
|
||||
super.scale(skeleton, stack, ticks);
|
||||
stack.scale(1.2F, 1.2F, 1.2F);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.client.render.entity;
|
|||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.WitchPonyModel;
|
||||
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
|
@ -18,11 +19,11 @@ public class WitchRenderer extends PonyRenderer<WitchEntity, WitchPonyModel> {
|
|||
private static final Identifier WITCH_TEXTURES = new Identifier("minelittlepony", "textures/entity/witch_pony.png");
|
||||
|
||||
public WitchRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.WITCH);
|
||||
super(context, ModelType.WITCH, TextureSupplier.of(WITCH_TEXTURES), BASE_MODEL_SCALE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HeldItemFeature<WitchEntity, WitchPonyModel> createItemHoldingLayer() {
|
||||
protected HeldItemFeature<WitchEntity, WitchPonyModel> createHeldItemFeature(EntityRendererFactory.Context context) {
|
||||
return new HeldItemFeature<WitchEntity, WitchPonyModel>(this) {
|
||||
@Override
|
||||
protected void preItemRender(WitchEntity entity, ItemStack drop, ModelTransformationMode transform, Arm hand, MatrixStack stack) {
|
||||
|
@ -31,15 +32,4 @@ public class WitchRenderer extends PonyRenderer<WitchEntity, WitchPonyModel> {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scale(WitchEntity entity, MatrixStack stack, float ticks) {
|
||||
super.scale(entity, stack, ticks);
|
||||
stack.scale(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(WitchEntity entity) {
|
||||
return WITCH_TEXTURES;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,77 +1,36 @@
|
|||
package com.minelittlepony.client.render.entity;
|
||||
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.mob.DrownedEntity;
|
||||
import net.minecraft.entity.mob.GiantEntity;
|
||||
import net.minecraft.entity.mob.HuskEntity;
|
||||
import net.minecraft.entity.mob.ZombieEntity;
|
||||
import net.minecraft.entity.mob.*;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.ZomponyModel;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
|
||||
public class ZomponyRenderer<Zombie extends ZombieEntity> extends PonyRenderer.Caster<Zombie, ZomponyModel<Zombie>> {
|
||||
public class ZomponyRenderer<Zombie extends HostileEntity> extends PonyRenderer<Zombie, ZomponyModel<Zombie>> {
|
||||
|
||||
public static final Identifier ZOMBIE = new Identifier("minelittlepony", "textures/entity/zombie/zombie_pony.png");
|
||||
public static final Identifier HUSK = new Identifier("minelittlepony", "textures/entity/zombie/husk_pony.png");
|
||||
public static final Identifier DROWNED = new Identifier("minelittlepony", "textures/entity/zombie/drowned_pony.png");
|
||||
|
||||
public ZomponyRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.ZOMBIE);
|
||||
public ZomponyRenderer(EntityRendererFactory.Context context, Identifier texture, float scale) {
|
||||
super(context, ModelType.ZOMBIE, TextureSupplier.of(texture), scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(Zombie entity) {
|
||||
return ZOMBIE;
|
||||
public static ZomponyRenderer<ZombieEntity> zombie(EntityRendererFactory.Context context) {
|
||||
return new ZomponyRenderer<>(context, ZOMBIE, 1);
|
||||
}
|
||||
|
||||
public static class Drowned extends ZomponyRenderer<DrownedEntity> {
|
||||
|
||||
public Drowned(EntityRendererFactory.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(DrownedEntity entity) {
|
||||
return DROWNED;
|
||||
}
|
||||
public static ZomponyRenderer<HuskEntity> husk(EntityRendererFactory.Context context) {
|
||||
return new ZomponyRenderer<>(context, HUSK, 1.0625F);
|
||||
}
|
||||
|
||||
public static class Husk extends ZomponyRenderer<HuskEntity> {
|
||||
|
||||
public Husk(EntityRendererFactory.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scale(HuskEntity entity, MatrixStack stack, float ticks) {
|
||||
super.scale(entity, stack, ticks);
|
||||
stack.scale(1.0625F, 1.0625F, 1.0625F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(HuskEntity entity) {
|
||||
return HUSK;
|
||||
}
|
||||
|
||||
public static ZomponyRenderer<DrownedEntity> drowned(EntityRendererFactory.Context context) {
|
||||
return new ZomponyRenderer<>(context, DROWNED, 1);
|
||||
}
|
||||
|
||||
public static class Giant extends PonyRenderer.Caster<GiantEntity, ZomponyModel<GiantEntity>> {
|
||||
|
||||
public Giant(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.ZOMBIE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scale(GiantEntity entity, MatrixStack stack, float ticks) {
|
||||
super.scale(entity, stack, ticks);
|
||||
stack.scale(3, 3, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(GiantEntity entity) {
|
||||
return ZOMBIE;
|
||||
}
|
||||
public static ZomponyRenderer<GiantEntity> giant(EntityRendererFactory.Context context) {
|
||||
return new ZomponyRenderer<>(context, ZOMBIE, 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,7 @@ import com.minelittlepony.client.render.entity.npc.textures.*;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
abstract class AbstractNpcRenderer<T extends MobEntity & VillagerDataContainer> extends PonyRenderer.Caster<T, ClientPonyModel<T>> {
|
||||
|
||||
private final TextureSupplier<T> baseTextures;
|
||||
abstract class AbstractNpcRenderer<T extends MobEntity & VillagerDataContainer> extends PonyRenderer<T, ClientPonyModel<T>> {
|
||||
|
||||
private final String entityType;
|
||||
|
||||
|
@ -29,16 +27,15 @@ abstract class AbstractNpcRenderer<T extends MobEntity & VillagerDataContainer>
|
|||
private final NpcClothingFeature<T, ClientPonyModel<T>, AbstractNpcRenderer<T>> clothing;
|
||||
|
||||
public AbstractNpcRenderer(EntityRendererFactory.Context context, String type, TextureSupplier<T> textureSupplier, TextureSupplier<String> formatter) {
|
||||
super(context, ModelType.getPlayerModel(Race.EARTH).getKey(false));
|
||||
super(context, ModelType.getPlayerModel(Race.EARTH).getKey(false), new SillyPonyTextureSupplier<>(textureSupplier, formatter));
|
||||
entityType = type;
|
||||
baseTextures = new SillyPonyTextureSupplier<>(textureSupplier, formatter);
|
||||
clothing = new NpcClothingFeature<>(this, entityType);
|
||||
addFeature(clothing);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addLayers(EntityRendererFactory.Context context) {
|
||||
addFeature(createItemHoldingLayer());
|
||||
protected void addFeatures(EntityRendererFactory.Context context) {
|
||||
addFeature(createHeldItemFeature(context));
|
||||
addFeature(new GearFeature<>(this));
|
||||
}
|
||||
|
||||
|
@ -89,9 +86,4 @@ abstract class AbstractNpcRenderer<T extends MobEntity & VillagerDataContainer>
|
|||
}
|
||||
return wearable.getDefaultTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(T villager) {
|
||||
return baseTextures.apply(villager);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.client.render.entity.npc;
|
|||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.IllagerPonyModel;
|
||||
import com.minelittlepony.client.render.entity.feature.IllagerHeldItemFeature;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
import com.minelittlepony.client.render.entity.PonyRenderer;
|
||||
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
||||
|
||||
|
@ -17,61 +18,32 @@ import net.minecraft.util.Identifier;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public abstract class IllagerPonyRenderer<T extends IllagerEntity> extends PonyRenderer<T, IllagerPonyModel<T>> {
|
||||
|
||||
public class IllagerPonyRenderer<T extends IllagerEntity> extends PonyRenderer<T, IllagerPonyModel<T>> {
|
||||
public static final Identifier ILLUSIONIST = new Identifier("minelittlepony", "textures/entity/illager/illusionist_pony.png");
|
||||
public static final Identifier EVOKER = new Identifier("minelittlepony", "textures/entity/illager/evoker_pony.png");
|
||||
public static final Identifier VINDICATOR = new Identifier("minelittlepony", "textures/entity/illager/vindicator_pony.png");
|
||||
|
||||
public IllagerPonyRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.ILLAGER);
|
||||
public IllagerPonyRenderer(EntityRendererFactory.Context context, Identifier texture) {
|
||||
super(context, ModelType.ILLAGER, TextureSupplier.of(texture), BASE_MODEL_SCALE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HeldItemFeature<T, IllagerPonyModel<T>> createItemHoldingLayer() {
|
||||
protected HeldItemFeature<T, IllagerPonyModel<T>> createHeldItemFeature(EntityRendererFactory.Context context) {
|
||||
return new IllagerHeldItemFeature<>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scale(T entity, MatrixStack stack, float ticks) {
|
||||
super.scale(entity, stack, ticks);
|
||||
stack.scale(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE);
|
||||
public static IllagerPonyRenderer<VindicatorEntity> vindicator(EntityRendererFactory.Context context) {
|
||||
return new IllagerPonyRenderer<>(context, VINDICATOR);
|
||||
}
|
||||
|
||||
public static class Vindicator extends IllagerPonyRenderer<VindicatorEntity> {
|
||||
|
||||
public Vindicator(EntityRendererFactory.Context context) {
|
||||
super(context);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(VindicatorEntity entity) {
|
||||
return VINDICATOR;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Evoker extends IllagerPonyRenderer<EvokerEntity> {
|
||||
|
||||
public Evoker(EntityRendererFactory.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(EvokerEntity entity) {
|
||||
return EVOKER;
|
||||
}
|
||||
public static IllagerPonyRenderer<EvokerEntity> evoker(EntityRendererFactory.Context context) {
|
||||
return new IllagerPonyRenderer<>(context, EVOKER);
|
||||
}
|
||||
|
||||
public static class Illusionist extends IllagerPonyRenderer<IllusionerEntity> {
|
||||
|
||||
public Illusionist(EntityRendererFactory.Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(IllusionerEntity entity) {
|
||||
return ILLUSIONIST;
|
||||
super(context, ILLUSIONIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,24 +7,20 @@ import net.minecraft.util.Identifier;
|
|||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.PillagerPonyModel;
|
||||
import com.minelittlepony.client.render.entity.feature.IllagerHeldItemFeature;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
import com.minelittlepony.client.render.entity.PonyRenderer;
|
||||
import com.minelittlepony.client.render.entity.feature.HeldItemFeature;
|
||||
|
||||
public class PillagerRenderer extends PonyRenderer<PillagerEntity, PillagerPonyModel<PillagerEntity>> {
|
||||
|
||||
private static final Identifier TEXTURES = new Identifier("minelittlepony", "textures/entity/illager/pillager_pony.png");
|
||||
private static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/entity/illager/pillager_pony.png");
|
||||
|
||||
public PillagerRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.PILLAGER);
|
||||
super(context, ModelType.PILLAGER, TextureSupplier.of(TEXTURE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(PillagerEntity entity) {
|
||||
return TEXTURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HeldItemFeature<PillagerEntity, PillagerPonyModel<PillagerEntity>> createItemHoldingLayer() {
|
||||
protected HeldItemFeature<PillagerEntity, PillagerPonyModel<PillagerEntity>> createHeldItemFeature(EntityRendererFactory.Context context) {
|
||||
return new IllagerHeldItemFeature<>(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +1,19 @@
|
|||
package com.minelittlepony.client.render.entity.npc;
|
||||
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.passive.WanderingTraderEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.entity.race.AlicornModel;
|
||||
import com.minelittlepony.client.render.entity.PonyRenderer;
|
||||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
|
||||
public class TraderRenderer extends PonyRenderer.Caster<WanderingTraderEntity, AlicornModel<WanderingTraderEntity>> {
|
||||
public class TraderRenderer extends PonyRenderer<WanderingTraderEntity, AlicornModel<WanderingTraderEntity>> {
|
||||
|
||||
public static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/entity/wandering_trader_pony.png");
|
||||
|
||||
public TraderRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, ModelType.ALICORN.getKey(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(WanderingTraderEntity entity) {
|
||||
return TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scale(WanderingTraderEntity entity, MatrixStack stack, float ticks) {
|
||||
super.scale(entity, stack, ticks);
|
||||
stack.scale(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE);
|
||||
super(context, ModelType.ALICORN.getKey(false), TextureSupplier.of(TEXTURE), BASE_MODEL_SCALE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,10 @@ public interface TextureSupplier<T> extends Function<T, Identifier> {
|
|||
};
|
||||
}
|
||||
|
||||
static <A> TextureSupplier<A> of(Identifier texture) {
|
||||
return a -> texture;
|
||||
}
|
||||
|
||||
static <A> TextureSupplier<A> memoize(Function<A, Identifier> func, Function<A, String> keyFunc) {
|
||||
final Map<String, Identifier> cache = new ConcurrentHashMap<>();
|
||||
return a -> cache.computeIfAbsent(keyFunc.apply(a), k -> func.apply(a));
|
||||
|
|
Loading…
Reference in a new issue