Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.particle.EntityFX;
- import net.minecraft.client.renderer.Tessellator;
- import net.minecraft.entity.Entity;
- import net.minecraft.util.MathHelper;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.world.World;
- import org.lwjgl.opengl.GL11;
- @SideOnly(Side.CLIENT)
- public class BulletHoleFX extends EntityFX {
- static final ResourceLocation textureBulletHole = new ResourceLocation("starwars", "textures/bullet_hole.png");
- int side;
- public BulletHoleFX(World world, double x, double y, double z, int sideHit) {
- super(world, x, y, z);
- this.motionX = this.motionY = this.motionZ = 0.0D;
- this.side = sideHit;
- this.particleMaxAge = 600;
- }
- 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_) {
- float f6 = ((float)this.particleAge + p_70539_2_) / (float)this.particleMaxAge;
- f6 *= f6;
- float f7 = 2.0F - f6 * 2.0F;
- if (f7 > 1.0F) {
- f7 = 1.0F;
- }
- Entity player = Minecraft.getMinecraft().thePlayer;
- interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)p_70539_2_;
- interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)p_70539_2_;
- interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)p_70539_2_;
- GL11.glPushMatrix();
- GL11.glDisable(2896);
- float f8 = 0.125F;
- float f9 = (float)(this.posX - interpPosX);
- float f10 = (float)(this.posY - interpPosY);
- float f11 = (float)(this.posZ - interpPosZ);
- float f12 = this.worldObj.getLightBrightness(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ));
- Minecraft.getMinecraft().getTextureManager().bindTexture(textureBulletHole);
- GL11.glEnable(3042);
- tessellator.startDrawingQuads();
- switch(this.side) {
- case 0:
- tessellator.addVertexWithUV((double)(f9 - f8), (double)f10 - 0.009999999776482582D, (double)(f11 - f8), 0.0D, 1.0D);
- tessellator.addVertexWithUV((double)(f9 + f8), (double)f10 - 0.009999999776482582D, (double)(f11 - f8), 1.0D, 1.0D);
- tessellator.addVertexWithUV((double)(f9 + f8), (double)f10 - 0.009999999776482582D, (double)(f11 + f8), 1.0D, 0.0D);
- tessellator.addVertexWithUV((double)(f9 - f8), (double)f10 - 0.009999999776482582D, (double)(f11 + f8), 0.0D, 0.0D);
- break;
- case 1:
- tessellator.addVertexWithUV((double)(f9 - f8), (double)f10 + 0.009999999776482582D, (double)(f11 + f8), 0.0D, 0.0D);
- tessellator.addVertexWithUV((double)(f9 + f8), (double)f10 + 0.009999999776482582D, (double)(f11 + f8), 1.0D, 0.0D);
- tessellator.addVertexWithUV((double)(f9 + f8), (double)f10 + 0.009999999776482582D, (double)(f11 - f8), 1.0D, 1.0D);
- tessellator.addVertexWithUV((double)(f9 - f8), (double)f10 + 0.009999999776482582D, (double)(f11 - f8), 0.0D, 1.0D);
- break;
- case 2:
- tessellator.addVertexWithUV((double)(f9 - f8), (double)(f10 + f8), (double)(f11 - 0.01F), 0.0D, 1.0D);
- tessellator.addVertexWithUV((double)(f9 + f8), (double)(f10 + f8), (double)(f11 - 0.01F), 1.0D, 1.0D);
- tessellator.addVertexWithUV((double)(f9 + f8), (double)(f10 - f8), (double)(f11 - 0.01F), 1.0D, 0.0D);
- tessellator.addVertexWithUV((double)(f9 - f8), (double)(f10 - f8), (double)(f11 - 0.01F), 0.0D, 0.0D);
- break;
- case 3:
- tessellator.addVertexWithUV((double)(f9 - f8), (double)(f10 - f8), (double)(f11 + 0.01F), 0.0D, 0.0D);
- tessellator.addVertexWithUV((double)(f9 + f8), (double)(f10 - f8), (double)(f11 + 0.01F), 1.0D, 0.0D);
- tessellator.addVertexWithUV((double)(f9 + f8), (double)(f10 + f8), (double)(f11 + 0.01F), 1.0D, 1.0D);
- tessellator.addVertexWithUV((double)(f9 - f8), (double)(f10 + f8), (double)(f11 + 0.01F), 0.0D, 1.0D);
- break;
- case 4:
- tessellator.addVertexWithUV((double)(f9 - 0.01F), (double)(f10 + f8), (double)(f11 + f8), 1.0D, 1.0D);
- tessellator.addVertexWithUV((double)(f9 - 0.01F), (double)(f10 + f8), (double)(f11 - f8), 1.0D, 0.0D);
- tessellator.addVertexWithUV((double)(f9 - 0.01F), (double)(f10 - f8), (double)(f11 - f8), 0.0D, 0.0D);
- tessellator.addVertexWithUV((double)(f9 - 0.01F), (double)(f10 - f8), (double)(f11 + f8), 0.0D, 1.0D);
- break;
- case 5:
- tessellator.addVertexWithUV((double)(f9 + 0.01F), (double)(f10 - f8), (double)(f11 + f8), 0.0D, 1.0D);
- tessellator.addVertexWithUV((double)(f9 + 0.01F), (double)(f10 - f8), (double)(f11 - f8), 0.0D, 0.0D);
- tessellator.addVertexWithUV((double)(f9 + 0.01F), (double)(f10 + f8), (double)(f11 - f8), 1.0D, 0.0D);
- tessellator.addVertexWithUV((double)(f9 + 0.01F), (double)(f10 + f8), (double)(f11 + f8), 1.0D, 1.0D);
- }
- tessellator.draw();
- GL11.glDisable(3042);
- GL11.glEnable(2896);
- GL11.glPopMatrix();
- }
- public void onUpdate() {
- if (this.particleAge++ >= this.particleMaxAge) {
- this.setDead();
- }
- }
- public int getFXLayer() {
- return 3;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement