Advertisement
Corosus

Untitled

Oct 23rd, 2011
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 18.85 KB | None | 0 0
  1. mod_ParticleMan.java
  2.  
  3. -----
  4.  
  5. package net.minecraft.src;
  6. // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
  7.  
  8. import java.lang.reflect.Field;
  9. import java.lang.reflect.Modifier;
  10. import java.util.HashMap;
  11. import java.util.Iterator;
  12. import java.util.List;
  13. import net.minecraft.client.Minecraft;
  14. import paulscode.sound.SoundSystem;
  15. import java.util.Random;
  16. import java.awt.event.MouseListener;
  17. import java.io.File;
  18. import java.io.FileInputStream;
  19. import java.io.FileOutputStream;
  20. import java.util.ArrayList;
  21.  
  22. import java.util.Map;
  23. import org.lwjgl.input.Keyboard;
  24. import org.lwjgl.input.Mouse;
  25.  
  26. import java.util.HashMap;
  27. import java.util.Iterator;
  28. import java.util.Map;
  29. import java.util.Set;
  30.  
  31.  
  32. public class mod_ParticleMan extends BaseMod
  33.     implements Runnable {
  34.  
  35.     public static String modName = "Particle Man";
  36.     public static Minecraft mc;
  37.     public static World worldRef;
  38.     public static World lastWorld;
  39.     public static EntityPlayer player;
  40.     public static int timeout;
  41.     public static String msg;
  42.     public static int color;
  43.     public static int defaultColor = 0xffffff;
  44.    
  45.     public static boolean ingui;
  46.    
  47.     public static List fxLayers[];
  48.    
  49.     public static boolean isCharging = false;
  50.  
  51.     public static List particles;
  52.    
  53.     public String Version() {
  54.         return "Version 1.0 for MC b1.8.1";
  55.     }
  56.  
  57.     public void run() {
  58.         try {
  59.             while(true) {
  60.                 if(mc == null) {
  61.                     mc = ModLoader.getMinecraftInstance();
  62.                 }
  63.  
  64.                 if(mc == null) {
  65.                     Thread.sleep(5000L);
  66.                 } else {
  67.                     if(mc.thePlayer == null) {
  68.                         Thread.sleep(5000L);
  69.                     } else {
  70.                         if (lastWorld != worldRef) {
  71.                             //worldSaver = null;
  72.                             lastWorld = worldRef;
  73.                             getFXLayers();
  74.                         }
  75.                        
  76.                         worldRef = mc.theWorld;
  77.                         player = mc.thePlayer;
  78.  
  79.                         Thread.sleep(5000L);
  80.                     }
  81.                 }
  82.             }
  83.         } catch(Throwable throwable) {
  84.             throwable.printStackTrace();
  85.         }
  86.     }
  87.  
  88.     public mod_ParticleMan() {
  89.        
  90.         //fireGlove = (new DominationRod(22501, 0)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/dominationrod/item.png")).setItemName("dominationrod");
  91.        
  92.         (new Thread(this)).start();
  93.         this.particles = new ArrayList();
  94.        
  95.         ModLoader.SetInGUIHook(this, true, false);
  96.         ModLoader.SetInGameHook(this, true, true);
  97.     }
  98.    
  99.     public void AddRenderer(Map var1) {
  100.        
  101.        
  102.         //effRainID = ModLoader.addOverride("/gui/items.png", "/item/raindrop.png");
  103.     }
  104.    
  105.     public void ModsLoaded() {
  106.         mc = ModLoader.getMinecraftInstance();
  107.         //this.rotEffRenderer = new RotatingEffectRenderer(mc.theWorld, mc.renderEngine);
  108.         //mc.entityRenderer = new EntityRendererProxyWeather(mc);
  109.     }
  110.  
  111.    
  112.     public static void displayMessage(String s, int i) {
  113.         msg = s;
  114.         timeout = 85;
  115.         color = i;
  116.     }
  117.     public static void dM(String s) {
  118.         displayMessage(s, defaultColor);
  119.     }
  120.     public static void dM(float f) {
  121.         displayMessage((new StringBuilder()).append(f).toString(), defaultColor);
  122.     }
  123.     public static void displayMessage(String s) {
  124.         displayMessage(s, defaultColor);
  125.     }
  126.    
  127.     public boolean OnTickInGame(Minecraft var1) {
  128.         if(!ingui) {
  129.             //playerLastTick = System.currentTimeMillis();
  130.             this.OSDHook(var1, false);
  131.         }
  132.  
  133.         ingui = false;
  134.         return true;
  135.     }
  136.     public boolean OnTickInGUI(Minecraft var1, GuiScreen gui) {
  137.         if (ModLoader.getMinecraftInstance().thePlayer != null) {
  138.             //long ticksRan = System.currentTimeMillis();
  139.             if (!(gui instanceof GuiContainer) && !(gui instanceof GuiChat)) {
  140.                 ingui = true;
  141.                 //lastTickRun = 0;
  142.             }
  143.  
  144.             //System.out.println(gui);
  145.             //playerTick(mc.thePlayer);
  146.         }
  147.  
  148.         return true;
  149.     }
  150.    
  151.     public static void OSDHook(Minecraft minecraft, boolean flag) {
  152.         if (worldRef == null) {
  153.             worldRef = ModLoader.getMinecraftInstance().theWorld;
  154.         }
  155.  
  156.         if (player == null) {
  157.             player = ModLoader.getMinecraftInstance().thePlayer;
  158.         }
  159.  
  160.         if (worldRef == null || player == null) {
  161.             return;
  162.         }
  163.  
  164.         tryPowers();
  165.  
  166.         if(timeout > 0 && msg != null) {
  167.             //ScaledResolution scaledresolution = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight);
  168.             minecraft.fontRenderer.drawStringWithShadow(msg, 3, 85, 0xffffff);
  169.             timeout--;
  170.         }
  171.     }
  172.    
  173.     public static void getFXLayers() {
  174.        
  175.         //fxLayers
  176.        
  177.         Field field = null;
  178.         try {
  179.             field = (EffectRenderer.class).getDeclaredField("b");
  180.             field.setAccessible(true);
  181.             fxLayers = (List[])field.get(ModLoader.getMinecraftInstance().effectRenderer);
  182.         } catch (Exception ex) {
  183.             try {
  184.                 field = (EffectRenderer.class).getDeclaredField("fxLayers");
  185.                 field.setAccessible(true);
  186.                 fxLayers = (List[])field.get(ModLoader.getMinecraftInstance().effectRenderer);
  187.             } catch (Exception ex2) {
  188.                 ex2.printStackTrace();
  189.             }
  190.         }
  191.     }
  192.    
  193.     public static void tryPowers() {
  194.        
  195.         if (Mouse.isButtonDown(0)) {
  196.             //System.out.println("0");
  197.         }
  198.        
  199.         if (player.inventory.getCurrentItem() == null || isCharging) {
  200.             if (Mouse.isButtonDown(1)) {
  201.                 gatherParticles();
  202.                 isCharging = true;
  203.             } else {
  204.                 if (isCharging) {
  205.                     isCharging = false;
  206.                     shootParticles();
  207.                 }
  208.             }
  209.         }
  210.        
  211.         if (Mouse.isButtonDown(2)) {
  212.             //System.out.println("2");
  213.         }
  214.    
  215.     }
  216.    
  217.     public static void shootParticles() {
  218.         float look = 0F;
  219.         //int height = 10;
  220.         double dist = 1F;
  221.         for(int i = 0; i < particles.size(); i++) {
  222.             Entity entity1 = (Entity)particles.get(i);
  223.            
  224.             entity1.motionX += ((double)(-Math.sin((player.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(player.rotationPitch / 180.0F * 3.1415927F)) * dist);
  225.            
  226.             entity1.motionY += (double)(-MathHelper.sin(player.rotationPitch / 180.0F * 3.1415927F) * dist);
  227.             //entity1.motionY = player.posY - 0D;
  228.             entity1.motionZ += ((double)(Math.cos((player.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(player.rotationPitch / 180.0F * 3.1415927F)) * dist);
  229.         }
  230.        
  231.        
  232.     }
  233.    
  234.     public static void gatherParticles() {
  235.         //Particles
  236.         if (fxLayers != null) {
  237.        
  238.             for (int layer = 0; layer < 4; layer++) {
  239.                 for(int i = 0; i < fxLayers[layer].size(); i++) {
  240.                     Entity entity1 = (Entity)fxLayers[layer].get(i);
  241.                     //if (player.canEntityBeSeen(entity1)) {
  242.                         if ((entity1 instanceof EntityFlameFX)) {
  243.                             if (player.getFoodStats().getFoodLevel() > 3) {
  244.                                 entity1.setEntityDead();
  245.                                 EntityFX ent = new EntityHurtingFlameFX(worldRef, entity1.posX, entity1.posY, entity1.posZ, entity1.motionX, entity1.motionY, entity1.motionZ);
  246.                                 particles.add(ent);
  247.                                 mc.effectRenderer.addEffect(ent);
  248.                                 if (particles.size() % 20 == 0) {
  249.                                     player.addExhaustion(1F);
  250.                                     //System.out.println("decre");
  251.                                 }
  252.                                
  253.                                 //System.out.println(player.getFoodStats().getFoodLevel());
  254.                                 moveEnt(entity1, player);
  255.                             }
  256.                            
  257.                            
  258.                             //((EntityFX)entity1).particleAge-=2;
  259.                             //if (((EntityFX)entity1).particleAge < 0) {
  260.                            
  261.                         } else if ((entity1 instanceof EntityHurtingFlameFX)) {
  262.                             if (((EntityFX)entity1).particleAge % 2 == 0) {
  263.                                 ((EntityFX)entity1).particleAge -= 1;
  264.                                 ((EntityFX)entity1).particleAge = 0;
  265.                                 ((EntityFX)entity1).renderDistanceWeight = 10D;
  266.                                
  267.                                 moveEnt(entity1, player);
  268.                                
  269.                                 if (entity1.isDead) {
  270.                                     particles.remove(entity1);
  271.                                 }
  272.                             }
  273.                         }
  274.                        
  275.                         //rustle!
  276.                         if (entity1.onGround) {
  277.                             //entity1.onGround = false;
  278.                             //entity1.motionY += entity1.rand.nextDouble() * entity1.motionX;
  279.                         }
  280.                        
  281.                         if (entity1.motionX < 0.01F && entity1.motionZ < 0.01F) {
  282.                             //entity1.motionY += entity1.rand.nextDouble() * 0.05;
  283.                         }
  284.                        
  285.                         //entity1.motionX += entity1.rand.nextDouble() * 0.03;
  286.                         //entity1.motionZ += entity1.rand.nextDouble() * 0.03;
  287.                         //entity1.motionY += entity1.rand.nextDouble() * 0.04;
  288.                        
  289.                     //if (canPushEntity(entity1)) {
  290.                     //if (!(entity1 instanceof EntityFlameFX)) {
  291.                    
  292.                        
  293.                     //}
  294.                 }
  295.             }
  296.         }
  297.     }
  298.    
  299.     public static void moveEnt(Entity ent, Entity center) {
  300.        
  301.         float look = 0F;
  302.         //int height = 10;
  303.         double dist = 2F;
  304.         double gatherX = center.posX + ((double)(-Math.sin((center.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(center.rotationPitch / 180.0F * 3.1415927F)) * dist);
  305.         double gatherY = center.posY + (double)(-MathHelper.sin(center.rotationPitch / 180.0F * 3.1415927F) * dist) - 0D; //center.posY - 0D;
  306.         double gatherZ = center.posZ + ((double)(Math.cos((center.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(center.rotationPitch / 180.0F * 3.1415927F)) * dist);
  307.        
  308.        
  309.        
  310.         double entDist = ent.getDistanceToEntity(center);
  311.        
  312.         double vecX = gatherX - ent.posX;
  313.         double vecY = gatherY - ent.posY;// + (double)(tNode.nextNode.bodyPiece.height / 2.0F) - (tNode.bodyPiece.posY + (double)(tNode.bodyPiece.height / 2.0F));
  314.         double vecZ = gatherZ - ent.posZ;
  315.        
  316.         //vecX = ent.posX - gatherX;
  317.         //vecY = ent.posY - gatherY;
  318.         //vecZ = ent.posZ - gatherZ;
  319.        
  320.         double var1 = 1.0D;
  321.        
  322.         /*double var2 = ent.prevRotationPitch + (ent.rotationPitch - ent.prevRotationPitch) * var1;
  323.         double var3 = ent.prevRotationYaw + (ent.rotationYaw - ent.prevRotationYaw) * var1;
  324.         double var4 = Math.cos(-var3 * 0.017453292F - 3.1415927F);
  325.         double var5 = Math.sin(-var3 * 0.017453292F - 3.1415927F);*/
  326.        
  327.         //return Vec3D.createVector((double)(var5 * var6), (double)var7, (double)(var4 * var6));
  328.        
  329.        
  330.        
  331.        
  332.        
  333.         //vecX = center.posX - ent.posX;
  334.         //vecY = center.posY - ent.posY;// + (double)(tNode.nextNode.bodyPiece.height / 2.0F) - (tNode.bodyPiece.posY + (double)(tNode.bodyPiece.height / 2.0F));
  335.         //vecZ = center.posZ - ent.posZ;
  336.        
  337.         //mod_MovePlus.displayMessage(new StringBuilder().append("vecX: " + vecX).toString());
  338.         //tNode.bodyPiece.vecX = vecX;//tNode.bodyPiece.posX - tNode.nextNode.bodyPiece.posX;
  339.         //tNode.bodyPiece.vecY = vecY;//tNode.bodyPiece.posY - tNode.nextNode.bodyPiece.posY;
  340.         //tNode.bodyPiece.vecZ = vecZ;//tNode.bodyPiece.posZ - tNode.nextNode.bodyPiece.posZ;
  341.         double var9 = (double)MathHelper.sqrt_double(vecX * vecX + vecY * vecY + vecZ * vecZ);
  342.         //double speed = 0.2D * (Math.sqrt(dist)/10.0F);
  343.         double speed = 0.02D;
  344.        
  345.         double newspeed = speed;// * (Math.sqrt(entDist)/1.0F);
  346.    
  347.         //tNode.bodyPiece.posX += vecX / var9 * newspeed;
  348.         //tNode.bodyPiece.posY += vecY / var9 * newspeed;
  349.         //tNode.bodyPiece.posZ += vecZ / var9 * newspeed;
  350.        
  351.         //tNode.bodyPiece.setPosition(tNode.bodyPiece.posX, tNode.bodyPiece.posY, tNode.bodyPiece.posZ);
  352.        
  353.         float pitch = (float)((Math.atan2(vecX, vecZ) * 180D) / 3.1415927410125732D);
  354.        
  355.         float f = (float)((Math.atan2(vecZ, vecX) * 180D) / 3.1415927410125732D);
  356.        
  357.         float angle = f;
  358.        
  359.         angle += 180;
  360.         //pitch += 180;
  361.        
  362.         /*for(angle = f; angle < -180F; angle += 360F) { }
  363.         for(; angle >= 180F; angle -= 360F) { }
  364.         for(pitch = pitch; pitch < -180F; pitch += 360F) { }
  365.         for(; pitch >= 180F; pitch -= 360F) { }*/
  366.        
  367.         for(angle = f; angle < 0F; angle += 360F) { }
  368.         for(; angle >= 360F; angle -= 360F) { }
  369.         for(pitch = pitch; pitch < 0F; pitch += 180F) { }
  370.         for(; pitch >= 180F; pitch -= 180F) { }
  371.        
  372.        
  373.        
  374.         /*System.out.println(angle);
  375.         System.out.println(pitch);
  376.         System.out.println("-");*/
  377.        
  378.         //enable once 3d trig works
  379.         angle = angle - 5;
  380.         //pitch = pitch - 10;
  381.        
  382.         //float rad_angle =
  383.        
  384.        
  385.         float rad_angle = angle * 0.01745329F;// * 3.1415927410125732F * 2F;
  386.         float rad_pitch = pitch * 0.01745329F * 2F;// * 3.1415927410125732F * 2F;
  387.        
  388.         float uhh = 1.0F;
  389.        
  390.         float newY = uhh * (float)Math.sin(rad_pitch);
  391.         float projection = uhh * (float)Math.cos(rad_pitch);
  392.         projection = 1.0F;
  393.         //System.out.println(projection);
  394.         float newX = projection * (float)Math.cos(rad_angle);
  395.         float newZ = projection * (float)Math.sin(rad_angle);
  396.        
  397.         float newVecX = newX / uhh;
  398.         float newVecY = newY / uhh;
  399.         float newVecZ = newZ / uhh;
  400.        
  401.         //float var6 = 1.0F;//(float)-Math.cos(-pitch * 0.017453292F);
  402.         //float var7 = (float)Math.sin(-pitch * 0.017453292F);
  403.        
  404.         //ent.motionX -= f3 * var6 * speed;//vecX / var9 * newspeed;
  405.         //ent.motionY -= var7 * speed;//vecY / var9 * newspeed;
  406.         //ent.motionZ += f4 * var6 * speed;// / var9 * newspeed;
  407.        
  408.         ent.motionY += vecY / var9 * speed;
  409.        
  410.         ent.motionX += newVecX * speed;
  411.         //ent.motionY += vecY * speed;
  412.         ent.motionZ += newVecZ * speed;
  413.        
  414.     }
  415. }
  416.  
  417.  
  418.  
  419.  
  420. -----
  421.  
  422.  
  423. EntityHurtingFlameFX.java
  424.  
  425.  
  426. -----
  427.  
  428. package net.minecraft.src;
  429.  
  430. import java.util.List;
  431.  
  432. import net.minecraft.src.EntityFX;
  433. import net.minecraft.src.Tessellator;
  434. import net.minecraft.src.World;
  435.  
  436. public class EntityHurtingFlameFX extends EntityFX {
  437.  
  438.    private float field_672_a;
  439.  
  440.  
  441.    public EntityHurtingFlameFX(World var1, double var2, double var4, double var6, double var8, double var10, double var12) {
  442.       super(var1, var2, var4, var6, var8, var10, var12);
  443.       this.motionX = this.motionX * 0.009999999776482582D + var8;
  444.       this.motionY = this.motionY * 0.009999999776482582D + var10;
  445.       this.motionZ = this.motionZ * 0.009999999776482582D + var12;
  446.       double var10000 = var2 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F);
  447.       var10000 = var4 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F);
  448.       var10000 = var6 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F);
  449.       this.field_672_a = this.particleScale;
  450.       this.particleRed = this.particleGreen = this.particleBlue = 1.0F;
  451.       this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)) + 4;
  452.       this.noClip = true;
  453.       this.particleTextureIndex = 48;
  454.    }
  455.  
  456.    public void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6, float var7) {
  457.       float var8 = ((float)this.particleAge + var2) / (float)this.particleMaxAge;
  458.       this.particleScale = this.field_672_a * (1.0F - var8 * var8 * 0.5F);
  459.       super.renderParticle(var1, var2, var3, var4, var5, var6, var7);
  460.    }
  461.  
  462.    public int func_35115_a(float var1) {
  463.       float var2 = ((float)this.particleAge + var1) / (float)this.particleMaxAge;
  464.       if(var2 < 0.0F) {
  465.          var2 = 0.0F;
  466.       }
  467.  
  468.       if(var2 > 1.0F) {
  469.          var2 = 1.0F;
  470.       }
  471.  
  472.       int var3 = super.func_35115_a(var1);
  473.       int var4 = var3 & 255;
  474.       int var5 = var3 >> 16 & 255;
  475.       var4 += (int)(var2 * 15.0F * 16.0F);
  476.       if(var4 > 240) {
  477.          var4 = 240;
  478.       }
  479.  
  480.       return var4 | var5 << 16;
  481.    }
  482.  
  483.    public float getEntityBrightness(float var1) {
  484.       float var2 = ((float)this.particleAge + var1) / (float)this.particleMaxAge;
  485.       if(var2 < 0.0F) {
  486.          var2 = 0.0F;
  487.       }
  488.  
  489.       if(var2 > 1.0F) {
  490.          var2 = 1.0F;
  491.       }
  492.  
  493.       float var3 = super.getEntityBrightness(var1);
  494.       return var3 * var2 + (1.0F - var2);
  495.    }
  496.  
  497.    public void onUpdate() {
  498.       this.prevPosX = this.posX;
  499.       this.prevPosY = this.posY;
  500.       this.prevPosZ = this.posZ;
  501.       if(this.particleAge++ >= this.particleMaxAge) {
  502.          this.setEntityDead();
  503.       }
  504.  
  505.       this.moveEntity(this.motionX, this.motionY, this.motionZ);
  506.       this.motionX *= 0.9599999785423279D;
  507.       this.motionY *= 0.9599999785423279D;
  508.       this.motionZ *= 0.9599999785423279D;
  509.       if(this.onGround) {
  510.          this.motionX *= 0.699999988079071D;
  511.          this.motionZ *= 0.699999988079071D;
  512.       }
  513.      
  514.       Entity var19 = null;
  515.       List var9 = null;
  516.      
  517.       var9 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ));
  518.      
  519.  
  520.       double var10 = 0.0D;
  521.       int var12;
  522.       int var14;
  523.      
  524.  
  525.       for(var12 = 0; var9 != null && var12 < var9.size(); ++var12) {
  526.           Entity var13 = (Entity)var9.get(var12);
  527.          
  528.           if (!(var13 instanceof EntityPlayer)) {
  529.          
  530.               if (var13.canBeCollidedWith()) {
  531.                   var13.motionX = this.motionX / 2;
  532.                   var13.motionY = this.motionY / 2;
  533.                   var13.motionZ = this.motionZ / 2;
  534.               }
  535.              
  536.               if(var13.canBeCollidedWith()) {
  537.                   if(var13.canBePushed()) {
  538.                       var13.getDistanceSqToEntity(this);
  539.    
  540.                       //if(this.fire > 0) {
  541.                      
  542.                       //}
  543.                      
  544.                       if (var13 instanceof EntityLiving && !var13.isDead && ((EntityLiving)var13).deathTime <= 0) {
  545.                           var13.attackEntityFrom(DamageSource.causeThrownDamage(this, this), 1);
  546.                           var13.fire = 300;
  547.                           ((EntityLiving)var13).field_9346_af = 0;
  548.                           this.setEntityDead();
  549.                       }
  550.                      
  551.                      
  552.                   }
  553.               }
  554.           }
  555.       }
  556.  
  557.    }
  558.    
  559.    public boolean canBeCollidedWith() {
  560.       return true;
  561.    }
  562. }
  563.  
  564.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement