Advertisement
Corosus

WindFX

Aug 28th, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.58 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import net.minecraft.src.EntityFX;
  4. import net.minecraft.src.Tessellator;
  5. import net.minecraft.src.World;
  6.  
  7. import java.awt.Color;
  8.  
  9. public class EntityWindFX extends EntityFX {
  10.  
  11.     public int age;
  12.     public float brightness;
  13.    
  14.    public EntityWindFX(World var1, double var2, double var4, double var6, double var8, double var10, double var12, double var14, int colorIndex) {
  15.       super(var1, var2, var4, var6, var8, var10, var12);
  16.       this.motionX = var8 + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F);
  17.       this.motionY = var10 + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F);
  18.       this.motionZ = var12 + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F);
  19.      
  20.       //Color IDS
  21.       //0 = black/regular/default
  22.       //1 = dirt
  23.       //2 = sand
  24.       //3 = water
  25.       //4 = snow
  26.       //5 = stone
  27.      
  28.       Color color = null;
  29.       if (colorIndex == 0) {
  30.           this.particleRed = this.particleGreen = this.particleBlue = this.rand.nextFloat() * 0.3F/* + 0.7F*/;
  31.       } else if (colorIndex == 1) {
  32.           color = new Color(0x79553a);
  33.       } else if (colorIndex == 2) {
  34.           color = new Color(0xd6cf98);
  35.       } else if (colorIndex == 3) {
  36.           color = new Color(0x002aDD);
  37.       } else if (colorIndex == 4) {
  38.           color = new Color(0xeeffff);
  39.       } else if (colorIndex == 5) {
  40.           color = new Color(0x747474);
  41.       }
  42.      
  43.       brightness = 0.7F;
  44.      
  45.       if (colorIndex != 0) {
  46.          
  47.           this.particleRed = color.getRed() / 255F;
  48.           this.particleGreen = color.getGreen() / 255F;
  49.           this.particleBlue = color.getBlue() / 255F;
  50.       }
  51.       this.particleScale = this.rand.nextFloat() * this.rand.nextFloat() * 6.0F + 1.0F;
  52.       this.particleMaxAge = (int)(16.0D/* / ((double)this.rand.nextFloat() * 0.8D + 0.2D)*/) + 2;
  53.       this.particleMaxAge = (int)((float)this.particleMaxAge * var14);
  54.       this.particleGravity = 1.0F;
  55.       this.particleScale = 5F;
  56.    }
  57.  
  58.    public void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6, float var7) {
  59.           float var8 = (float)(this.particleTextureIndex % 16) / 16.0F;
  60.           float var9 = var8 + 0.0624375F;
  61.           float var10 = (float)(this.particleTextureIndex / 16) / 16.0F;
  62.           float var11 = var10 + 0.0624375F;
  63.           float var12 = 0.1F * this.particleScale;
  64.          
  65.           //this is no way to code this!
  66.           /*
  67.            * | UltraMoogleMan | Corosus: You need to use a VBO if you're going to use particles, really
  68.            * | UltraMoogleMan | Just bang the vertices into the buffer and then render it in one command
  69.            * | UltraMoogleMan | Corosus: The problem, I think, you'll run into (if you haven't already) is that immediate mode is -slow-
  70.            * | UltraMoogleMan | This is partly the reason why I was going on last night about how ideally, notch would eventually just eject most of the orientation code he has and replace it with a simple vertex shader that does single-weighted boned anims
  71.            * | UltraMoogleMan | Corosus: To boil it down simply, ideally you wouldn't *have* to manually transform every box's vertices by the relevant transform matrix before rendering it
  72.            * | UltraMoogleMan | This is done on the CPU and is slow
  73.            * | UltraMoogleMan | Corosus: Ideally you'd just have a matrix array with one entry for the entire cube
  74.            * | UltraMoogleMan | Corosus: Then you'd have a vertex array with the coords for the cube
  75.            * or better -> | UltraMoogleMan | You'd have a matrix array with all of the transform matrices
  76.            * | UltraMoogleMan | Corosus: Then have an array with all the vertices of all the cubes
  77.            * | UltraMoogleMan | Un-transformed
  78.            * | UltraMoogleMan | Then you just do two glDrawArrays
  79.            * | UltraMoogleMan | Of course, this is predicated on using GLSL
  80.            * | UltraMoogleMan | So you'd need to crack that nut
  81.            * | UltraMoogleMan | But it shouldn't be too hard
  82.            *
  83.            *
  84.            *
  85.            *
  86.            *
  87.           */
  88.           /*for (int i = 0; i < 0; i++) {
  89.               for (int j = 0; j < 3; j++) {
  90.                   for (int k = 0; k < 3; k++) {*/
  91.              
  92.                       float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)var2 - interpPosX);
  93.                       float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)var2 - interpPosY);
  94.                       float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)var2 - interpPosZ);
  95.                       //var13 += i;//rand.nextInt(6)-3;
  96.                       //var14 += j;
  97.                       //var15 += k;
  98.                       float var16 = this.getEntityBrightness(var2) * brightness;
  99.                       var1.setColorOpaque_F(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16);
  100.                       var1.addVertexWithUV((double)(var13 - var3 * var12 - var6 * var12), (double)(var14 - var4 * var12), (double)(var15 - var5 * var12 - var7 * var12), (double)var9, (double)var11);
  101.                       var1.addVertexWithUV((double)(var13 - var3 * var12 + var6 * var12), (double)(var14 + var4 * var12), (double)(var15 - var5 * var12 + var7 * var12), (double)var9, (double)var10);
  102.                       var1.addVertexWithUV((double)(var13 + var3 * var12 + var6 * var12), (double)(var14 + var4 * var12), (double)(var15 + var5 * var12 + var7 * var12), (double)var8, (double)var10);
  103.                       var1.addVertexWithUV((double)(var13 + var3 * var12 - var6 * var12), (double)(var14 - var4 * var12), (double)(var15 + var5 * var12 - var7 * var12), (double)var8, (double)var11);
  104.                   /*}
  105.               }
  106.           }*/
  107.        }
  108.  
  109.    public void onUpdate() {
  110.      
  111.       this.prevPosX = this.posX;
  112.       this.prevPosY = this.posY;
  113.       this.prevPosZ = this.posZ;
  114.       if(this.particleAge++ >= this.particleMaxAge) {
  115.          this.setEntityDead();
  116.       }
  117.  
  118.       this.particleTextureIndex = 7 - this.particleAge * 8 / this.particleMaxAge;
  119.       this.particleTextureIndex = 7 - this.particleAge * 8 / this.particleMaxAge;
  120.       //this.particleTextureIndex = mod_EntMover.effWindID;
  121.       //this.motionY += 0.0040D;
  122.       //this.motionY -= 0.04D * (double)this.particleGravity;
  123.       this.motionY -= 0.05000000074505806D;
  124.  
  125.       float var20 = 0.98F;
  126.  
  127.       this.motionX *= (double)var20;
  128.       this.motionY *= (double)var20;
  129.       this.motionZ *= (double)var20;
  130.       this.moveEntity(this.motionX, this.motionY, this.motionZ);
  131.       /*this.motionX *= 0.8999999761581421D;
  132.       this.motionY *= 0.8999999761581421D;
  133.       this.motionZ *= 0.8999999761581421D;
  134.       if(this.onGround) {
  135.          this.motionX *= 0.699999988079071D;
  136.          this.motionZ *= 0.699999988079071D;
  137.       }*/
  138.      
  139.  
  140.    }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement