package net.minecraft.client.renderer.entity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.model.WindChargeModel; import net.minecraft.client.model.geom.ModelLayers; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge; @Environment(EnvType.CLIENT) public class WindChargeRenderer extends EntityRenderer { private static final float MIN_CAMERA_DISTANCE_SQUARED = Mth.square(3.5F); private static final ResourceLocation TEXTURE_LOCATION = ResourceLocation.withDefaultNamespace("textures/entity/projectiles/wind_charge.png"); private final WindChargeModel model; public WindChargeRenderer(EntityRendererProvider.Context context) { super(context); this.model = new WindChargeModel(context.bakeLayer(ModelLayers.WIND_CHARGE)); } public void render(AbstractWindCharge entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { if (entity.tickCount >= 2 || !(this.entityRenderDispatcher.camera.getEntity().distanceToSqr(entity) < MIN_CAMERA_DISTANCE_SQUARED)) { float f = entity.tickCount + partialTick; VertexConsumer vertexConsumer = bufferSource.getBuffer(RenderType.breezeWind(TEXTURE_LOCATION, this.xOffset(f) % 1.0F, 0.0F)); this.model.setupAnim(entity, 0.0F, 0.0F, f, 0.0F, 0.0F); this.model.renderToBuffer(poseStack, vertexConsumer, packedLight, OverlayTexture.NO_OVERLAY); super.render(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); } } protected float xOffset(float tickCount) { return tickCount * 0.03F; } /** * Returns the location of an entity's texture. */ public ResourceLocation getTextureLocation(AbstractWindCharge entity) { return TEXTURE_LOCATION; } }