51 lines
1.8 KiB
Java
51 lines
1.8 KiB
Java
package net.minecraft.client.renderer.entity;
|
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import com.mojang.math.Axis;
|
|
import net.fabricmc.api.EnvType;
|
|
import net.fabricmc.api.Environment;
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
|
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
|
|
import net.minecraft.client.renderer.texture.TextureAtlas;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.world.entity.item.PrimedTnt;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public class TntRenderer extends EntityRenderer<PrimedTnt> {
|
|
private final BlockRenderDispatcher blockRenderer;
|
|
|
|
public TntRenderer(EntityRendererProvider.Context context) {
|
|
super(context);
|
|
this.shadowRadius = 0.5F;
|
|
this.blockRenderer = context.getBlockRenderDispatcher();
|
|
}
|
|
|
|
public void render(PrimedTnt entity, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource buffer, int packedLight) {
|
|
poseStack.pushPose();
|
|
poseStack.translate(0.0F, 0.5F, 0.0F);
|
|
int i = entity.getFuse();
|
|
if (i - partialTicks + 1.0F < 10.0F) {
|
|
float f = 1.0F - (i - partialTicks + 1.0F) / 10.0F;
|
|
f = Mth.clamp(f, 0.0F, 1.0F);
|
|
f *= f;
|
|
f *= f;
|
|
float g = 1.0F + f * 0.3F;
|
|
poseStack.scale(g, g, g);
|
|
}
|
|
|
|
poseStack.mulPose(Axis.YP.rotationDegrees(-90.0F));
|
|
poseStack.translate(-0.5F, -0.5F, 0.5F);
|
|
poseStack.mulPose(Axis.YP.rotationDegrees(90.0F));
|
|
TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, entity.getBlockState(), poseStack, buffer, packedLight, i / 5 % 2 == 0);
|
|
poseStack.popPose();
|
|
super.render(entity, entityYaw, partialTicks, poseStack, buffer, packedLight);
|
|
}
|
|
|
|
/**
|
|
* Returns the location of an entity's texture.
|
|
*/
|
|
public ResourceLocation getTextureLocation(PrimedTnt entity) {
|
|
return TextureAtlas.LOCATION_BLOCKS;
|
|
}
|
|
}
|