65 lines
		
	
	
	
		
			2.5 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
	
		
			2.5 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package net.minecraft.client.particle;
 | |
| 
 | |
| import com.mojang.blaze3d.vertex.PoseStack;
 | |
| import com.mojang.blaze3d.vertex.VertexConsumer;
 | |
| import com.mojang.math.Axis;
 | |
| import net.fabricmc.api.EnvType;
 | |
| import net.fabricmc.api.Environment;
 | |
| import net.minecraft.client.Camera;
 | |
| import net.minecraft.client.Minecraft;
 | |
| import net.minecraft.client.model.GuardianModel;
 | |
| import net.minecraft.client.model.Model;
 | |
| import net.minecraft.client.model.geom.ModelLayers;
 | |
| import net.minecraft.client.multiplayer.ClientLevel;
 | |
| import net.minecraft.client.renderer.MultiBufferSource;
 | |
| import net.minecraft.client.renderer.RenderType;
 | |
| import net.minecraft.client.renderer.entity.ElderGuardianRenderer;
 | |
| import net.minecraft.client.renderer.texture.OverlayTexture;
 | |
| import net.minecraft.core.particles.SimpleParticleType;
 | |
| import net.minecraft.util.ARGB;
 | |
| import net.minecraft.util.Mth;
 | |
| 
 | |
| @Environment(EnvType.CLIENT)
 | |
| public class MobAppearanceParticle extends Particle {
 | |
| 	private final Model model;
 | |
| 	private final RenderType renderType = RenderType.entityTranslucent(ElderGuardianRenderer.GUARDIAN_ELDER_LOCATION);
 | |
| 
 | |
| 	MobAppearanceParticle(ClientLevel level, double x, double y, double z) {
 | |
| 		super(level, x, y, z);
 | |
| 		this.model = new GuardianModel(Minecraft.getInstance().getEntityModels().bakeLayer(ModelLayers.ELDER_GUARDIAN));
 | |
| 		this.gravity = 0.0F;
 | |
| 		this.lifetime = 30;
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public ParticleRenderType getRenderType() {
 | |
| 		return ParticleRenderType.CUSTOM;
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public void renderCustom(PoseStack poseStack, MultiBufferSource bufferSource, Camera camera, float partialTick) {
 | |
| 		float f = (this.age + partialTick) / this.lifetime;
 | |
| 		float g = 0.05F + 0.5F * Mth.sin(f * (float) Math.PI);
 | |
| 		int i = ARGB.colorFromFloat(g, 1.0F, 1.0F, 1.0F);
 | |
| 		poseStack.pushPose();
 | |
| 		poseStack.mulPose(camera.rotation());
 | |
| 		poseStack.mulPose(Axis.XP.rotationDegrees(60.0F - 150.0F * f));
 | |
| 		float h = 0.42553192F;
 | |
| 		poseStack.scale(0.42553192F, -0.42553192F, -0.42553192F);
 | |
| 		poseStack.translate(0.0F, -0.56F, 3.5F);
 | |
| 		VertexConsumer vertexConsumer = bufferSource.getBuffer(this.renderType);
 | |
| 		this.model.renderToBuffer(poseStack, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY, i);
 | |
| 		poseStack.popPose();
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public void render(VertexConsumer buffer, Camera camera, float partialTick) {
 | |
| 	}
 | |
| 
 | |
| 	@Environment(EnvType.CLIENT)
 | |
| 	public static class Provider implements ParticleProvider<SimpleParticleType> {
 | |
| 		public Particle createParticle(SimpleParticleType type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
 | |
| 			return new MobAppearanceParticle(level, x, y, z);
 | |
| 		}
 | |
| 	}
 | |
| }
 |