Advertisement
Exception_Prototype

Untitled

Jul 31st, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.33 KB | None | 0 0
  1. import cpw.mods.fml.relauncher.Side;
  2. import cpw.mods.fml.relauncher.SideOnly;
  3. import net.minecraft.client.Minecraft;
  4. import net.minecraft.client.particle.EntityFX;
  5. import net.minecraft.client.renderer.Tessellator;
  6. import net.minecraft.entity.Entity;
  7. import net.minecraft.util.MathHelper;
  8. import net.minecraft.util.ResourceLocation;
  9. import net.minecraft.world.World;
  10. import org.lwjgl.opengl.GL11;
  11.  
  12. @SideOnly(Side.CLIENT)
  13. public class BulletHoleFX extends EntityFX {
  14.    static final ResourceLocation textureBulletHole = new ResourceLocation("starwars", "textures/bullet_hole.png");
  15.    int side;
  16.  
  17.    public BulletHoleFX(World world, double x, double y, double z, int sideHit) {
  18.       super(world, x, y, z);
  19.       this.motionX = this.motionY = this.motionZ = 0.0D;
  20.       this.side = sideHit;
  21.       this.particleMaxAge = 600;
  22.    }
  23.  
  24.    public void renderParticle(Tessellator tessellator, float p_70539_2_, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) {
  25.       float f6 = ((float)this.particleAge + p_70539_2_) / (float)this.particleMaxAge;
  26.       f6 *= f6;
  27.       float f7 = 2.0F - f6 * 2.0F;
  28.       if (f7 > 1.0F) {
  29.          f7 = 1.0F;
  30.       }
  31.  
  32.       Entity player = Minecraft.getMinecraft().thePlayer;
  33.       interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)p_70539_2_;
  34.       interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)p_70539_2_;
  35.       interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)p_70539_2_;
  36.       GL11.glPushMatrix();
  37.       GL11.glDisable(2896);
  38.       float f8 = 0.125F;
  39.       float f9 = (float)(this.posX - interpPosX);
  40.       float f10 = (float)(this.posY - interpPosY);
  41.       float f11 = (float)(this.posZ - interpPosZ);
  42.       float f12 = this.worldObj.getLightBrightness(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ));
  43.       Minecraft.getMinecraft().getTextureManager().bindTexture(textureBulletHole);
  44.       GL11.glEnable(3042);
  45.       tessellator.startDrawingQuads();
  46.       switch(this.side) {
  47.       case 0:
  48.          tessellator.addVertexWithUV((double)(f9 - f8), (double)f10 - 0.009999999776482582D, (double)(f11 - f8), 0.0D, 1.0D);
  49.          tessellator.addVertexWithUV((double)(f9 + f8), (double)f10 - 0.009999999776482582D, (double)(f11 - f8), 1.0D, 1.0D);
  50.          tessellator.addVertexWithUV((double)(f9 + f8), (double)f10 - 0.009999999776482582D, (double)(f11 + f8), 1.0D, 0.0D);
  51.          tessellator.addVertexWithUV((double)(f9 - f8), (double)f10 - 0.009999999776482582D, (double)(f11 + f8), 0.0D, 0.0D);
  52.          break;
  53.       case 1:
  54.          tessellator.addVertexWithUV((double)(f9 - f8), (double)f10 + 0.009999999776482582D, (double)(f11 + f8), 0.0D, 0.0D);
  55.          tessellator.addVertexWithUV((double)(f9 + f8), (double)f10 + 0.009999999776482582D, (double)(f11 + f8), 1.0D, 0.0D);
  56.          tessellator.addVertexWithUV((double)(f9 + f8), (double)f10 + 0.009999999776482582D, (double)(f11 - f8), 1.0D, 1.0D);
  57.          tessellator.addVertexWithUV((double)(f9 - f8), (double)f10 + 0.009999999776482582D, (double)(f11 - f8), 0.0D, 1.0D);
  58.          break;
  59.       case 2:
  60.          tessellator.addVertexWithUV((double)(f9 - f8), (double)(f10 + f8), (double)(f11 - 0.01F), 0.0D, 1.0D);
  61.          tessellator.addVertexWithUV((double)(f9 + f8), (double)(f10 + f8), (double)(f11 - 0.01F), 1.0D, 1.0D);
  62.          tessellator.addVertexWithUV((double)(f9 + f8), (double)(f10 - f8), (double)(f11 - 0.01F), 1.0D, 0.0D);
  63.          tessellator.addVertexWithUV((double)(f9 - f8), (double)(f10 - f8), (double)(f11 - 0.01F), 0.0D, 0.0D);
  64.          break;
  65.       case 3:
  66.          tessellator.addVertexWithUV((double)(f9 - f8), (double)(f10 - f8), (double)(f11 + 0.01F), 0.0D, 0.0D);
  67.          tessellator.addVertexWithUV((double)(f9 + f8), (double)(f10 - f8), (double)(f11 + 0.01F), 1.0D, 0.0D);
  68.          tessellator.addVertexWithUV((double)(f9 + f8), (double)(f10 + f8), (double)(f11 + 0.01F), 1.0D, 1.0D);
  69.          tessellator.addVertexWithUV((double)(f9 - f8), (double)(f10 + f8), (double)(f11 + 0.01F), 0.0D, 1.0D);
  70.          break;
  71.       case 4:
  72.          tessellator.addVertexWithUV((double)(f9 - 0.01F), (double)(f10 + f8), (double)(f11 + f8), 1.0D, 1.0D);
  73.          tessellator.addVertexWithUV((double)(f9 - 0.01F), (double)(f10 + f8), (double)(f11 - f8), 1.0D, 0.0D);
  74.          tessellator.addVertexWithUV((double)(f9 - 0.01F), (double)(f10 - f8), (double)(f11 - f8), 0.0D, 0.0D);
  75.          tessellator.addVertexWithUV((double)(f9 - 0.01F), (double)(f10 - f8), (double)(f11 + f8), 0.0D, 1.0D);
  76.          break;
  77.       case 5:
  78.          tessellator.addVertexWithUV((double)(f9 + 0.01F), (double)(f10 - f8), (double)(f11 + f8), 0.0D, 1.0D);
  79.          tessellator.addVertexWithUV((double)(f9 + 0.01F), (double)(f10 - f8), (double)(f11 - f8), 0.0D, 0.0D);
  80.          tessellator.addVertexWithUV((double)(f9 + 0.01F), (double)(f10 + f8), (double)(f11 - f8), 1.0D, 0.0D);
  81.          tessellator.addVertexWithUV((double)(f9 + 0.01F), (double)(f10 + f8), (double)(f11 + f8), 1.0D, 1.0D);
  82.       }
  83.  
  84.       tessellator.draw();
  85.       GL11.glDisable(3042);
  86.       GL11.glEnable(2896);
  87.       GL11.glPopMatrix();
  88.    }
  89.  
  90.    public void onUpdate() {
  91.       if (this.particleAge++ >= this.particleMaxAge) {
  92.          this.setDead();
  93.       }
  94.  
  95.    }
  96.  
  97.    public int getFXLayer() {
  98.       return 3;
  99.    }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement