73 lines
2.9 KiB
Java
73 lines
2.9 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.client.renderer.entity;
|
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import net.minecraft.client.model.EntityModel;
|
|
import net.minecraft.client.model.PufferfishBigModel;
|
|
import net.minecraft.client.model.PufferfishMidModel;
|
|
import net.minecraft.client.model.PufferfishSmallModel;
|
|
import net.minecraft.client.model.geom.ModelLayers;
|
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|
import net.minecraft.client.renderer.entity.MobRenderer;
|
|
import net.minecraft.client.renderer.entity.state.EntityRenderState;
|
|
import net.minecraft.client.renderer.entity.state.PufferfishRenderState;
|
|
import net.minecraft.client.renderer.state.CameraRenderState;
|
|
import net.minecraft.resources.Identifier;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.world.entity.animal.Pufferfish;
|
|
|
|
public class PufferfishRenderer
|
|
extends MobRenderer<Pufferfish, PufferfishRenderState, EntityModel<EntityRenderState>> {
|
|
private static final Identifier PUFFER_LOCATION = Identifier.withDefaultNamespace("textures/entity/fish/pufferfish.png");
|
|
private final EntityModel<EntityRenderState> small;
|
|
private final EntityModel<EntityRenderState> mid;
|
|
private final EntityModel<EntityRenderState> big = this.getModel();
|
|
|
|
public PufferfishRenderer(EntityRendererProvider.Context context) {
|
|
super(context, new PufferfishBigModel(context.bakeLayer(ModelLayers.PUFFERFISH_BIG)), 0.2f);
|
|
this.mid = new PufferfishMidModel(context.bakeLayer(ModelLayers.PUFFERFISH_MEDIUM));
|
|
this.small = new PufferfishSmallModel(context.bakeLayer(ModelLayers.PUFFERFISH_SMALL));
|
|
}
|
|
|
|
@Override
|
|
public Identifier getTextureLocation(PufferfishRenderState state) {
|
|
return PUFFER_LOCATION;
|
|
}
|
|
|
|
@Override
|
|
public PufferfishRenderState createRenderState() {
|
|
return new PufferfishRenderState();
|
|
}
|
|
|
|
@Override
|
|
protected float getShadowRadius(PufferfishRenderState state) {
|
|
return 0.1f + 0.1f * (float)state.puffState;
|
|
}
|
|
|
|
@Override
|
|
public void submit(PufferfishRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera) {
|
|
this.model = switch (state.puffState) {
|
|
case 0 -> this.small;
|
|
case 1 -> this.mid;
|
|
default -> this.big;
|
|
};
|
|
super.submit(state, poseStack, submitNodeCollector, camera);
|
|
}
|
|
|
|
@Override
|
|
public void extractRenderState(Pufferfish entity, PufferfishRenderState state, float partialTicks) {
|
|
super.extractRenderState(entity, state, partialTicks);
|
|
state.puffState = entity.getPuffState();
|
|
}
|
|
|
|
@Override
|
|
protected void setupRotations(PufferfishRenderState state, PoseStack poseStack, float bodyRot, float entityScale) {
|
|
poseStack.translate(0.0f, Mth.cos(state.ageInTicks * 0.05f) * 0.08f, 0.0f);
|
|
super.setupRotations(state, poseStack, bodyRot, entityScale);
|
|
}
|
|
}
|
|
|