Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mod_ParticleMan.java
- -----
- package net.minecraft.src;
- // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
- import java.lang.reflect.Field;
- import java.lang.reflect.Modifier;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.List;
- import net.minecraft.client.Minecraft;
- import paulscode.sound.SoundSystem;
- import java.util.Random;
- import java.awt.event.MouseListener;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.util.ArrayList;
- import java.util.Map;
- import org.lwjgl.input.Keyboard;
- import org.lwjgl.input.Mouse;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.Map;
- import java.util.Set;
- public class mod_ParticleMan extends BaseMod
- implements Runnable {
- public static String modName = "Particle Man";
- public static Minecraft mc;
- public static World worldRef;
- public static World lastWorld;
- public static EntityPlayer player;
- public static int timeout;
- public static String msg;
- public static int color;
- public static int defaultColor = 0xffffff;
- public static boolean ingui;
- public static List fxLayers[];
- public static boolean isCharging = false;
- public static List particles;
- public String Version() {
- return "Version 1.0 for MC b1.8.1";
- }
- public void run() {
- try {
- while(true) {
- if(mc == null) {
- mc = ModLoader.getMinecraftInstance();
- }
- if(mc == null) {
- Thread.sleep(5000L);
- } else {
- if(mc.thePlayer == null) {
- Thread.sleep(5000L);
- } else {
- if (lastWorld != worldRef) {
- //worldSaver = null;
- lastWorld = worldRef;
- getFXLayers();
- }
- worldRef = mc.theWorld;
- player = mc.thePlayer;
- Thread.sleep(5000L);
- }
- }
- }
- } catch(Throwable throwable) {
- throwable.printStackTrace();
- }
- }
- public mod_ParticleMan() {
- //fireGlove = (new DominationRod(22501, 0)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/dominationrod/item.png")).setItemName("dominationrod");
- (new Thread(this)).start();
- this.particles = new ArrayList();
- ModLoader.SetInGUIHook(this, true, false);
- ModLoader.SetInGameHook(this, true, true);
- }
- public void AddRenderer(Map var1) {
- //effRainID = ModLoader.addOverride("/gui/items.png", "/item/raindrop.png");
- }
- public void ModsLoaded() {
- mc = ModLoader.getMinecraftInstance();
- //this.rotEffRenderer = new RotatingEffectRenderer(mc.theWorld, mc.renderEngine);
- //mc.entityRenderer = new EntityRendererProxyWeather(mc);
- }
- public static void displayMessage(String s, int i) {
- msg = s;
- timeout = 85;
- color = i;
- }
- public static void dM(String s) {
- displayMessage(s, defaultColor);
- }
- public static void dM(float f) {
- displayMessage((new StringBuilder()).append(f).toString(), defaultColor);
- }
- public static void displayMessage(String s) {
- displayMessage(s, defaultColor);
- }
- public boolean OnTickInGame(Minecraft var1) {
- if(!ingui) {
- //playerLastTick = System.currentTimeMillis();
- this.OSDHook(var1, false);
- }
- ingui = false;
- return true;
- }
- public boolean OnTickInGUI(Minecraft var1, GuiScreen gui) {
- if (ModLoader.getMinecraftInstance().thePlayer != null) {
- //long ticksRan = System.currentTimeMillis();
- if (!(gui instanceof GuiContainer) && !(gui instanceof GuiChat)) {
- ingui = true;
- //lastTickRun = 0;
- }
- //System.out.println(gui);
- //playerTick(mc.thePlayer);
- }
- return true;
- }
- public static void OSDHook(Minecraft minecraft, boolean flag) {
- if (worldRef == null) {
- worldRef = ModLoader.getMinecraftInstance().theWorld;
- }
- if (player == null) {
- player = ModLoader.getMinecraftInstance().thePlayer;
- }
- if (worldRef == null || player == null) {
- return;
- }
- tryPowers();
- if(timeout > 0 && msg != null) {
- //ScaledResolution scaledresolution = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight);
- minecraft.fontRenderer.drawStringWithShadow(msg, 3, 85, 0xffffff);
- timeout--;
- }
- }
- public static void getFXLayers() {
- //fxLayers
- Field field = null;
- try {
- field = (EffectRenderer.class).getDeclaredField("b");
- field.setAccessible(true);
- fxLayers = (List[])field.get(ModLoader.getMinecraftInstance().effectRenderer);
- } catch (Exception ex) {
- try {
- field = (EffectRenderer.class).getDeclaredField("fxLayers");
- field.setAccessible(true);
- fxLayers = (List[])field.get(ModLoader.getMinecraftInstance().effectRenderer);
- } catch (Exception ex2) {
- ex2.printStackTrace();
- }
- }
- }
- public static void tryPowers() {
- if (Mouse.isButtonDown(0)) {
- //System.out.println("0");
- }
- if (player.inventory.getCurrentItem() == null || isCharging) {
- if (Mouse.isButtonDown(1)) {
- gatherParticles();
- isCharging = true;
- } else {
- if (isCharging) {
- isCharging = false;
- shootParticles();
- }
- }
- }
- if (Mouse.isButtonDown(2)) {
- //System.out.println("2");
- }
- }
- public static void shootParticles() {
- float look = 0F;
- //int height = 10;
- double dist = 1F;
- for(int i = 0; i < particles.size(); i++) {
- Entity entity1 = (Entity)particles.get(i);
- entity1.motionX += ((double)(-Math.sin((player.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(player.rotationPitch / 180.0F * 3.1415927F)) * dist);
- entity1.motionY += (double)(-MathHelper.sin(player.rotationPitch / 180.0F * 3.1415927F) * dist);
- //entity1.motionY = player.posY - 0D;
- entity1.motionZ += ((double)(Math.cos((player.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(player.rotationPitch / 180.0F * 3.1415927F)) * dist);
- }
- }
- public static void gatherParticles() {
- //Particles
- if (fxLayers != null) {
- for (int layer = 0; layer < 4; layer++) {
- for(int i = 0; i < fxLayers[layer].size(); i++) {
- Entity entity1 = (Entity)fxLayers[layer].get(i);
- //if (player.canEntityBeSeen(entity1)) {
- if ((entity1 instanceof EntityFlameFX)) {
- if (player.getFoodStats().getFoodLevel() > 3) {
- entity1.setEntityDead();
- EntityFX ent = new EntityHurtingFlameFX(worldRef, entity1.posX, entity1.posY, entity1.posZ, entity1.motionX, entity1.motionY, entity1.motionZ);
- particles.add(ent);
- mc.effectRenderer.addEffect(ent);
- if (particles.size() % 20 == 0) {
- player.addExhaustion(1F);
- //System.out.println("decre");
- }
- //System.out.println(player.getFoodStats().getFoodLevel());
- moveEnt(entity1, player);
- }
- //((EntityFX)entity1).particleAge-=2;
- //if (((EntityFX)entity1).particleAge < 0) {
- } else if ((entity1 instanceof EntityHurtingFlameFX)) {
- if (((EntityFX)entity1).particleAge % 2 == 0) {
- ((EntityFX)entity1).particleAge -= 1;
- ((EntityFX)entity1).particleAge = 0;
- ((EntityFX)entity1).renderDistanceWeight = 10D;
- moveEnt(entity1, player);
- if (entity1.isDead) {
- particles.remove(entity1);
- }
- }
- }
- //rustle!
- if (entity1.onGround) {
- //entity1.onGround = false;
- //entity1.motionY += entity1.rand.nextDouble() * entity1.motionX;
- }
- if (entity1.motionX < 0.01F && entity1.motionZ < 0.01F) {
- //entity1.motionY += entity1.rand.nextDouble() * 0.05;
- }
- //entity1.motionX += entity1.rand.nextDouble() * 0.03;
- //entity1.motionZ += entity1.rand.nextDouble() * 0.03;
- //entity1.motionY += entity1.rand.nextDouble() * 0.04;
- //if (canPushEntity(entity1)) {
- //if (!(entity1 instanceof EntityFlameFX)) {
- //}
- }
- }
- }
- }
- public static void moveEnt(Entity ent, Entity center) {
- float look = 0F;
- //int height = 10;
- double dist = 2F;
- double gatherX = center.posX + ((double)(-Math.sin((center.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(center.rotationPitch / 180.0F * 3.1415927F)) * dist);
- double gatherY = center.posY + (double)(-MathHelper.sin(center.rotationPitch / 180.0F * 3.1415927F) * dist) - 0D; //center.posY - 0D;
- double gatherZ = center.posZ + ((double)(Math.cos((center.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(center.rotationPitch / 180.0F * 3.1415927F)) * dist);
- double entDist = ent.getDistanceToEntity(center);
- double vecX = gatherX - ent.posX;
- double vecY = gatherY - ent.posY;// + (double)(tNode.nextNode.bodyPiece.height / 2.0F) - (tNode.bodyPiece.posY + (double)(tNode.bodyPiece.height / 2.0F));
- double vecZ = gatherZ - ent.posZ;
- //vecX = ent.posX - gatherX;
- //vecY = ent.posY - gatherY;
- //vecZ = ent.posZ - gatherZ;
- double var1 = 1.0D;
- /*double var2 = ent.prevRotationPitch + (ent.rotationPitch - ent.prevRotationPitch) * var1;
- double var3 = ent.prevRotationYaw + (ent.rotationYaw - ent.prevRotationYaw) * var1;
- double var4 = Math.cos(-var3 * 0.017453292F - 3.1415927F);
- double var5 = Math.sin(-var3 * 0.017453292F - 3.1415927F);*/
- //return Vec3D.createVector((double)(var5 * var6), (double)var7, (double)(var4 * var6));
- //vecX = center.posX - ent.posX;
- //vecY = center.posY - ent.posY;// + (double)(tNode.nextNode.bodyPiece.height / 2.0F) - (tNode.bodyPiece.posY + (double)(tNode.bodyPiece.height / 2.0F));
- //vecZ = center.posZ - ent.posZ;
- //mod_MovePlus.displayMessage(new StringBuilder().append("vecX: " + vecX).toString());
- //tNode.bodyPiece.vecX = vecX;//tNode.bodyPiece.posX - tNode.nextNode.bodyPiece.posX;
- //tNode.bodyPiece.vecY = vecY;//tNode.bodyPiece.posY - tNode.nextNode.bodyPiece.posY;
- //tNode.bodyPiece.vecZ = vecZ;//tNode.bodyPiece.posZ - tNode.nextNode.bodyPiece.posZ;
- double var9 = (double)MathHelper.sqrt_double(vecX * vecX + vecY * vecY + vecZ * vecZ);
- //double speed = 0.2D * (Math.sqrt(dist)/10.0F);
- double speed = 0.02D;
- double newspeed = speed;// * (Math.sqrt(entDist)/1.0F);
- //tNode.bodyPiece.posX += vecX / var9 * newspeed;
- //tNode.bodyPiece.posY += vecY / var9 * newspeed;
- //tNode.bodyPiece.posZ += vecZ / var9 * newspeed;
- //tNode.bodyPiece.setPosition(tNode.bodyPiece.posX, tNode.bodyPiece.posY, tNode.bodyPiece.posZ);
- float pitch = (float)((Math.atan2(vecX, vecZ) * 180D) / 3.1415927410125732D);
- float f = (float)((Math.atan2(vecZ, vecX) * 180D) / 3.1415927410125732D);
- float angle = f;
- angle += 180;
- //pitch += 180;
- /*for(angle = f; angle < -180F; angle += 360F) { }
- for(; angle >= 180F; angle -= 360F) { }
- for(pitch = pitch; pitch < -180F; pitch += 360F) { }
- for(; pitch >= 180F; pitch -= 360F) { }*/
- for(angle = f; angle < 0F; angle += 360F) { }
- for(; angle >= 360F; angle -= 360F) { }
- for(pitch = pitch; pitch < 0F; pitch += 180F) { }
- for(; pitch >= 180F; pitch -= 180F) { }
- /*System.out.println(angle);
- System.out.println(pitch);
- System.out.println("-");*/
- //enable once 3d trig works
- angle = angle - 5;
- //pitch = pitch - 10;
- //float rad_angle =
- float rad_angle = angle * 0.01745329F;// * 3.1415927410125732F * 2F;
- float rad_pitch = pitch * 0.01745329F * 2F;// * 3.1415927410125732F * 2F;
- float uhh = 1.0F;
- float newY = uhh * (float)Math.sin(rad_pitch);
- float projection = uhh * (float)Math.cos(rad_pitch);
- projection = 1.0F;
- //System.out.println(projection);
- float newX = projection * (float)Math.cos(rad_angle);
- float newZ = projection * (float)Math.sin(rad_angle);
- float newVecX = newX / uhh;
- float newVecY = newY / uhh;
- float newVecZ = newZ / uhh;
- //float var6 = 1.0F;//(float)-Math.cos(-pitch * 0.017453292F);
- //float var7 = (float)Math.sin(-pitch * 0.017453292F);
- //ent.motionX -= f3 * var6 * speed;//vecX / var9 * newspeed;
- //ent.motionY -= var7 * speed;//vecY / var9 * newspeed;
- //ent.motionZ += f4 * var6 * speed;// / var9 * newspeed;
- ent.motionY += vecY / var9 * speed;
- ent.motionX += newVecX * speed;
- //ent.motionY += vecY * speed;
- ent.motionZ += newVecZ * speed;
- }
- }
- -----
- EntityHurtingFlameFX.java
- -----
- package net.minecraft.src;
- import java.util.List;
- import net.minecraft.src.EntityFX;
- import net.minecraft.src.Tessellator;
- import net.minecraft.src.World;
- public class EntityHurtingFlameFX extends EntityFX {
- private float field_672_a;
- public EntityHurtingFlameFX(World var1, double var2, double var4, double var6, double var8, double var10, double var12) {
- super(var1, var2, var4, var6, var8, var10, var12);
- this.motionX = this.motionX * 0.009999999776482582D + var8;
- this.motionY = this.motionY * 0.009999999776482582D + var10;
- this.motionZ = this.motionZ * 0.009999999776482582D + var12;
- double var10000 = var2 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F);
- var10000 = var4 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F);
- var10000 = var6 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F);
- this.field_672_a = this.particleScale;
- this.particleRed = this.particleGreen = this.particleBlue = 1.0F;
- this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)) + 4;
- this.noClip = true;
- this.particleTextureIndex = 48;
- }
- public void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6, float var7) {
- float var8 = ((float)this.particleAge + var2) / (float)this.particleMaxAge;
- this.particleScale = this.field_672_a * (1.0F - var8 * var8 * 0.5F);
- super.renderParticle(var1, var2, var3, var4, var5, var6, var7);
- }
- public int func_35115_a(float var1) {
- float var2 = ((float)this.particleAge + var1) / (float)this.particleMaxAge;
- if(var2 < 0.0F) {
- var2 = 0.0F;
- }
- if(var2 > 1.0F) {
- var2 = 1.0F;
- }
- int var3 = super.func_35115_a(var1);
- int var4 = var3 & 255;
- int var5 = var3 >> 16 & 255;
- var4 += (int)(var2 * 15.0F * 16.0F);
- if(var4 > 240) {
- var4 = 240;
- }
- return var4 | var5 << 16;
- }
- public float getEntityBrightness(float var1) {
- float var2 = ((float)this.particleAge + var1) / (float)this.particleMaxAge;
- if(var2 < 0.0F) {
- var2 = 0.0F;
- }
- if(var2 > 1.0F) {
- var2 = 1.0F;
- }
- float var3 = super.getEntityBrightness(var1);
- return var3 * var2 + (1.0F - var2);
- }
- public void onUpdate() {
- this.prevPosX = this.posX;
- this.prevPosY = this.posY;
- this.prevPosZ = this.posZ;
- if(this.particleAge++ >= this.particleMaxAge) {
- this.setEntityDead();
- }
- this.moveEntity(this.motionX, this.motionY, this.motionZ);
- this.motionX *= 0.9599999785423279D;
- this.motionY *= 0.9599999785423279D;
- this.motionZ *= 0.9599999785423279D;
- if(this.onGround) {
- this.motionX *= 0.699999988079071D;
- this.motionZ *= 0.699999988079071D;
- }
- Entity var19 = null;
- List var9 = null;
- var9 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ));
- double var10 = 0.0D;
- int var12;
- int var14;
- for(var12 = 0; var9 != null && var12 < var9.size(); ++var12) {
- Entity var13 = (Entity)var9.get(var12);
- if (!(var13 instanceof EntityPlayer)) {
- if (var13.canBeCollidedWith()) {
- var13.motionX = this.motionX / 2;
- var13.motionY = this.motionY / 2;
- var13.motionZ = this.motionZ / 2;
- }
- if(var13.canBeCollidedWith()) {
- if(var13.canBePushed()) {
- var13.getDistanceSqToEntity(this);
- //if(this.fire > 0) {
- //}
- if (var13 instanceof EntityLiving && !var13.isDead && ((EntityLiving)var13).deathTime <= 0) {
- var13.attackEntityFrom(DamageSource.causeThrownDamage(this, this), 1);
- var13.fire = 300;
- ((EntityLiving)var13).field_9346_af = 0;
- this.setEntityDead();
- }
- }
- }
- }
- }
- }
- public boolean canBeCollidedWith() {
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement