package com.tiedup.remake.client.renderer; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Axis; import com.tiedup.remake.client.animation.render.RenderConstants; import com.tiedup.remake.client.model.DamselModel; import com.tiedup.remake.compat.wildfire.WildfireCompat; import com.tiedup.remake.compat.wildfire.render.WildfireDamselLayer; import com.tiedup.remake.entities.AbstractTiedUpNpc; import net.minecraft.client.model.HumanoidArmorModel; import net.minecraft.client.model.geom.ModelLayers; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.HumanoidMobRenderer; import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer; import net.minecraft.client.renderer.entity.layers.ItemInHandLayer; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; /** * Renderer for AbstractTiedUpNpc and all subtypes (Kidnapper, Elite, Archer, Merchant, Shiny). * *
Uses ISkinnedEntity interface for polymorphic texture lookup. * Each entity subclass overrides getSkinTexture() to return the appropriate texture. * *
Issue #19 fix: Replaced 6+ instanceof checks with single interface call.
*/
@OnlyIn(Dist.CLIENT)
public class DamselRenderer
extends HumanoidMobRenderer Issue #19 fix: Uses ISkinnedEntity interface instead of instanceof cascade.
* Each entity subclass implements getSkinTexture() to return appropriate texture.
*/
@Override
public ResourceLocation getTextureLocation(AbstractTiedUpNpc entity) {
// ISkinnedEntity provides polymorphic skin texture lookup
// Each entity type (Damsel, Kidnapper, Elite, Archer, Merchant, Shiny)
// overrides getSkinTexture() to return the correct texture
return entity.getSkinTexture();
}
/**
* Apply scale transformation.
*/
@Override
protected void scale(
AbstractTiedUpNpc entity,
PoseStack poseStack,
float partialTick
) {
poseStack.scale(0.9375f, 0.9375f, 0.9375f);
}
/**
* Setup rotations for the entity.
*
* DOG pose: After Y rotation is applied by parent, add X rotation
* to make the body horizontal. This is applied in entity-local space,
* so the "belly down" direction follows the entity's facing.
*/
@Override
protected void setupRotations(
AbstractTiedUpNpc entity,
PoseStack poseStack,
float ageInTicks,
float rotationYaw,
float partialTicks
) {
// Call parent to apply Y rotation (body facing)
super.setupRotations(
entity,
poseStack,
ageInTicks,
rotationYaw,
partialTicks
);
// DOG pose: Apply X rotation to make body horizontal
// This happens AFTER Y rotation, so it's in entity-local space
if (entity.isDogPose()) {
// Rotate -90° on X axis around the model's pivot point
// Pivot at waist height (12 model units = 0.75 blocks up from feet)
poseStack.translate(0, 0.75, 0);
poseStack.mulPose(Axis.XP.rotationDegrees(-90));
poseStack.translate(0, -0.75, 0);
}
}
}