minecraft-src/net/minecraft/client/model/AgeableHierarchicalModel.java
2025-07-04 01:41:11 +03:00

39 lines
1.5 KiB
Java

package net.minecraft.client.model;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import java.util.function.Function;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
@Environment(EnvType.CLIENT)
public abstract class AgeableHierarchicalModel<E extends Entity> extends HierarchicalModel<E> {
private final float youngScaleFactor;
private final float bodyYOffset;
public AgeableHierarchicalModel(float youngScaleFactor, float bodyYOffset) {
this(youngScaleFactor, bodyYOffset, RenderType::entityCutoutNoCull);
}
public AgeableHierarchicalModel(float youngScaleFactor, float bodyYOffset, Function<ResourceLocation, RenderType> renderType) {
super(renderType);
this.bodyYOffset = bodyYOffset;
this.youngScaleFactor = youngScaleFactor;
}
@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay, int color) {
if (this.young) {
poseStack.pushPose();
poseStack.scale(this.youngScaleFactor, this.youngScaleFactor, this.youngScaleFactor);
poseStack.translate(0.0F, this.bodyYOffset / 16.0F, 0.0F);
this.root().render(poseStack, buffer, packedLight, packedOverlay, color);
poseStack.popPose();
} else {
this.root().render(poseStack, buffer, packedLight, packedOverlay, color);
}
}
}