Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.krokoyt.fa.particles;
- import com.mojang.blaze3d.platform.GlStateManager;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.particle.IParticleFactory;
- import net.minecraft.client.particle.IParticleRenderType;
- import net.minecraft.client.particle.Particle;
- import net.minecraft.client.renderer.ActiveRenderInfo;
- import net.minecraft.client.renderer.BufferBuilder;
- import net.minecraft.client.renderer.Tessellator;
- import net.minecraft.client.renderer.texture.TextureManager;
- import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
- import net.minecraft.particles.IParticleData;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.World;
- import net.minecraftforge.api.distmarker.Dist;
- import net.minecraftforge.api.distmarker.OnlyIn;
- public class Footstep extends Particle{
- private static final ResourceLocation FOOTPRINT_TEXTURE = new ResourceLocation("textures/particle/footprint.png");
- private int footstepAge;
- private final int footstepMaxAge;
- private final TextureManager currentFootSteps;
- protected Footstep(TextureManager currentFootStepsIn, World worldIn, double posXIn, double posYIn, double posZIn) {
- super(worldIn, posXIn, posYIn, posZIn);
- this.currentFootSteps = currentFootStepsIn;
- this.motionX = 0.0D;
- this.motionY = 0.0D;
- this.motionZ = 0.0D;
- this.footstepMaxAge = 200;
- // TODO Auto-generated constructor stub
- }
- @Override
- public void renderParticle(BufferBuilder buffer, ActiveRenderInfo entityIn, float partialTicks, float rotationX,
- float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
- float f = ((float)this.footstepAge + partialTicks) / (float)this.footstepMaxAge;
- f = f * f;
- float f1 = 2.0F - f * 2.0F;
- if (f1 > 1.0F)
- {
- f1 = 1.0F;
- }
- f1 = f1 * 0.2F;
- GlStateManager.disableLighting();
- float f2 = 0.125F;
- float f3 = (float)(this.posX - interpPosX);
- float f4 = (float)(this.posY - interpPosY);
- float f5 = (float)(this.posZ - interpPosZ);
- float f6 = this.world.getBrightness(new BlockPos(this.posX, this.posY, this.posZ));
- this.currentFootSteps.bindTexture(FOOTPRINT_TEXTURE);
- com.mojang.blaze3d.platform.GlStateManager.enableBlend();
- GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
- buffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
- buffer.pos((double)(f3 - 0.125F), (double)f4, (double)(f5 + 0.125F)).tex(0.0D, 1.0D).color(f6, f6, f6, f1).endVertex();
- buffer.pos((double)(f3 + 0.125F), (double)f4, (double)(f5 + 0.125F)).tex(1.0D, 1.0D).color(f6, f6, f6, f1).endVertex();
- buffer.pos((double)(f3 + 0.125F), (double)f4, (double)(f5 - 0.125F)).tex(1.0D, 0.0D).color(f6, f6, f6, f1).endVertex();
- buffer.pos((double)(f3 - 0.125F), (double)f4, (double)(f5 - 0.125F)).tex(0.0D, 0.0D).color(f6, f6, f6, f1).endVertex();
- Tessellator.getInstance().draw();
- GlStateManager.disableBlend();
- GlStateManager.enableLighting();
- }
- public void onUpdate()
- {
- ++this.footstepAge;
- if (this.footstepAge == this.footstepMaxAge)
- {
- this.setExpired();
- }
- }
- /**
- * Retrieve what effect layer (what texture) the particle should be rendered with. 0 for the particle sprite sheet,
- * 1 for the main Texture atlas, and 3 for a custom texture
- */
- public int getFXLayer()
- {
- return 3;
- }
- @Override
- public IParticleRenderType getRenderType() {
- // TODO Auto-generated method stub
- return null;
- }
- @OnlyIn(Dist.CLIENT)
- public static class Factory implements IParticleFactory
- {
- @Override
- public Particle makeParticle(IParticleData typeIn, World worldIn, double x, double y, double z, double xSpeed,
- double ySpeed, double zSpeed) {
- return new Footstep(Minecraft.getInstance().textureManager, worldIn, x, y, z);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement