Advertisement
Camellias_

Untitled

Jul 31st, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.97 KB | None | 0 0
  1. package com.camellias.voidaicarcania.client.particles;
  2.  
  3. import com.camellias.voidaicarcania.Reference;
  4.  
  5. import net.minecraft.client.Minecraft;
  6. import net.minecraft.client.particle.Particle;
  7. import net.minecraft.client.renderer.BufferBuilder;
  8. import net.minecraft.client.renderer.texture.TextureAtlasSprite;
  9. import net.minecraft.entity.Entity;
  10. import net.minecraft.util.ResourceLocation;
  11. import net.minecraft.world.World;
  12.  
  13. public class VoidEssenceParticle extends Particle
  14. {
  15.     private final ResourceLocation TEXTURE = new ResourceLocation(Reference.MODID + ":textures/particles/particle_void_essence");
  16.    
  17.     public VoidEssenceParticle(World world, double x, double y, double z, double velocityX, double velocityY, double velocityZ)
  18.     {
  19.         super(world, x, y, z, velocityX, velocityY, velocityZ);
  20.        
  21.         particleMaxAge = 20;
  22.        
  23.         final float ALPHA_VALUE = 0.99F;
  24.         this.particleAlpha = ALPHA_VALUE;
  25.        
  26.         motionX = velocityX;
  27.         motionY = velocityY;
  28.         motionZ = velocityZ;
  29.        
  30.         TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(TEXTURE.toString());
  31.         setParticleTexture(sprite);
  32.     }
  33.    
  34.     @Override
  35.     public int getFXLayer()
  36.     {
  37.         return 1;
  38.     }
  39.    
  40.     @Override
  41.     public int getBrightnessForRender(float partialTicks)
  42.     {
  43.         final int FULL_BRIGHTNESS_VALUE = 0xf000f0;
  44.         return FULL_BRIGHTNESS_VALUE;
  45.     }
  46.    
  47.     @Override
  48.     public boolean shouldDisableDepth()
  49.     {
  50.         return false;
  51.     }
  52.    
  53.     @Override
  54.     public void onUpdate()
  55.     {
  56.         super.onUpdate();
  57.        
  58.         if(this.particleMaxAge-- <= 0)
  59.         {
  60.             this.setExpired();
  61.         }
  62.     }
  63.    
  64.     @Override
  65.     public void renderParticle(BufferBuilder bufferBuilder, Entity entity, float partialTick,
  66.             float edgeLRdirectionX, float edgeUDdirectionY, float edgeLRdirectionZ,
  67.             float edgeUDdirectionX, float edgeUDdirectionZ)
  68.     {
  69.         double minU = this.particleTexture.getMinU();
  70.         double maxU = this.particleTexture.getMaxU();
  71.         double minV = this.particleTexture.getMinV();
  72.         double maxV = this.particleTexture.getMaxV();
  73.        
  74.         double scale = 0.1F * this.particleScale;
  75.         final double scaleLR = scale;
  76.         final double scaleUD = scale;
  77.         double x = this.prevPosX + (this.posX - this.prevPosX) * partialTick - interpPosX;
  78.         double y = this.prevPosY + (this.posY - this.prevPosY) * partialTick - interpPosY;
  79.         double z = this.prevPosZ + (this.posZ - this.prevPosZ) * partialTick - interpPosZ;
  80.        
  81.         int combinedBrightness = this.getBrightnessForRender(partialTick);
  82.         int skyLightTimes16 = combinedBrightness >> 16 & 65535;
  83.         int blockLightTimes16 = combinedBrightness & 65535;
  84.        
  85.         bufferBuilder.pos(x - edgeLRdirectionX * scaleLR - edgeUDdirectionX * scaleUD,
  86.                 y - edgeUDdirectionY * scaleUD,
  87.                 z - edgeLRdirectionZ * scaleLR - edgeUDdirectionZ * scaleUD)
  88.                 .tex(maxU, maxV)
  89.                 .color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha)
  90.                 .lightmap(skyLightTimes16, blockLightTimes16)
  91.                 .endVertex();
  92.        
  93.         bufferBuilder.pos(x - edgeLRdirectionX * scaleLR + edgeUDdirectionX * scaleUD,
  94.                 y + edgeUDdirectionY * scaleUD,
  95.                 z - edgeLRdirectionZ * scaleLR + edgeUDdirectionZ * scaleUD)
  96.                 .tex(maxU, minV)
  97.                 .color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha)
  98.                 .lightmap(skyLightTimes16, blockLightTimes16)
  99.                 .endVertex();
  100.        
  101.         bufferBuilder.pos(x + edgeLRdirectionX * scaleLR + edgeUDdirectionX * scaleUD,
  102.                 y + edgeUDdirectionY * scaleUD,
  103.                 z + edgeLRdirectionZ * scaleLR + edgeUDdirectionZ * scaleUD)
  104.                 .tex(minU, minV)
  105.                 .color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha)
  106.                 .lightmap(skyLightTimes16, blockLightTimes16)
  107.                 .endVertex();
  108.        
  109.         bufferBuilder.pos(x + edgeLRdirectionX * scaleLR - edgeUDdirectionX * scaleUD,
  110.                 y - edgeUDdirectionY * scaleUD,
  111.                 z + edgeLRdirectionZ * scaleLR - edgeUDdirectionZ * scaleUD)
  112.                 .tex(minU, maxV)
  113.                 .color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha)
  114.                 .lightmap(skyLightTimes16, blockLightTimes16)
  115.                 .endVertex();
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement