From 07ac511e17780734f58e73cfdeb2da3f33a0f7ff Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sun, 4 Aug 2013 21:21:07 -0400 Subject: [PATCH] Fixed Tesla zapping --- .../textures/items/linker.png | Bin 1018 -> 752 bytes src/resonantinduction/base/Vector3.java | 7 +++-- .../battery/BlockBattery.java | 28 ++++++++++-------- .../contractor/BlockEMContractor.java | 2 +- .../multimeter/BlockMultimeter.java | 2 +- src/resonantinduction/tesla/BlockTesla.java | 2 +- .../tesla/TileEntityTesla.java | 12 ++++---- 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/resources/assets/resonantinduction/textures/items/linker.png b/resources/assets/resonantinduction/textures/items/linker.png index 2302f1855662402866771cfd251399747f4c88ec..dd0070459365badb9bc1e5f0c43338a97d7a7df0 100644 GIT binary patch delta 640 zcmV-`0)PGb2k-@udw&97NkllVlnKy#eUW>KwHQ7)I!YPHbo^?xuN4l$d}uvjcG9*;2^ zjj-KraXz1QASVz@0L^hY97Zr0M6FgssZ@d(|A8odhp6lz^4}l^ZxG5)h|E`hH=Rzg zTrP1u9&x!`96{~^uyg4s6bc~_2p|@V-5in=Q||xypOfiG3^AEZa5x-rI-MZsokd!# z0p#wI$s`hqgnw>;j9jl*+o1z}nP9zMGlYn%J^8q&pnzrRJ# za|B{9h(sbN6bilpR8_rI$m?$(08&^Keiok32=x1X7Nx%wNa18M8RYYM-vCsqgTcUO z3Zw|B=0B5yPNxG!Q6Qusy=x$%pi-%D6#S;3-EO1X?SJ0-g=Y~qe(>(83W~+zhx)gw z2xCv6@Dl(%wf=FhD_Zvf*>ouXXu$2z~?kMkr26D zj?VxZ&1RDgl5qkuIyC>*!*A0AZ0`daKr|ZVQY1kVgyxuj+X2+;b)L`Xgw5$_dm1u? z)B*ue8hHpJl}d3W%xN%&o*-$iUG6nKI0H}!)nC$>Y$(Mw1Krz^7BOzS$ybQN%C`Jm z0q9zAdHcC1PT%(d<3cj5H6%xa9_G5fls*BT5zy4_BtX5i-mAvVe8+3K8zY~Y^8|Q! a1pWd@?(Sk<%|z4y0000}{+vNb?2CkuxUg?# zF}s6|*;j*EYlcv$DFnDmyzna(H;C*S)9aSqRh?BDd@t&f?lm15CRwi>+9<;LtuV>UV&ZkU!NM}Ywq6p`Fvhg*xK59 zJ_1%D;4DV_@3=Iv*@bIuqOiU=y-2*7#NRJZSpPik3L;w=BgMYMKU0q3~Qqi~?f!c`166ove zlhM&pB|#fp>8aensdjpLS`|VmR|(9@%s>HV1O|mr?SM*DV0?T$s^0pJ;|-iSFgZD? z1gM(NE&=O5smSGWvcJDC)oRs`KzDbyK!8mEy{q20z&52ifURn40|Zz+=bDt~X~FgN zb$tT-uz$6+ReE}Qv?7)MV@fL7H~JZ=8Ac?7D+J7>25jJNL{WkFMcn)0Q44sWrKLsM z+uK!sciK@g_o$Zpkl|`7Bt_KZKRrG5C(zW?Bm)BjQM3R8oK#>;3~EG-B;GKuSVUJ= zR-zHTxw%=N02SD46csu;I&=;IK=or|W10v^*nf(#?Douc7F36B`o_cxEoPi zkK`=k8dtfId1AtPhY2>K4K^L)B1+2&g@O*A+5+k-5HU(PRI*t*oz|2@)6t2jof9}4 zFn@aMRqYZ9IuVhM&dyHlKS{6(0cS4YdNbaO5CEKo88IS$z?94admHlE7d+@l=0=n@ zm5Im`ph3(3eKj{D*lWB0000 entitiesHit = world.getEntitiesWithinAABBExcludingEntity(null, boxToScan); double closestEntity = reachDistance; + if (entitiesHit == null || entitiesHit.isEmpty()) { return null; diff --git a/src/resonantinduction/battery/BlockBattery.java b/src/resonantinduction/battery/BlockBattery.java index 5ecdd0bb..b2185002 100644 --- a/src/resonantinduction/battery/BlockBattery.java +++ b/src/resonantinduction/battery/BlockBattery.java @@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; +import resonantinduction.ResonantInduction; import resonantinduction.base.BlockBase; import resonantinduction.render.BlockRenderingHandler; import cpw.mods.fml.relauncher.Side; @@ -26,7 +27,8 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider { public BlockBattery(int id) { - super("battery", id, Material.iron); + super("battery", id); + this.func_111022_d(ResonantInduction.PREFIX + "machine"); } @Override @@ -43,28 +45,28 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider return true; } - + @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int id) + public void onNeighborBlockChange(World world, int x, int y, int z, int id) { - if(!world.isRemote) + if (!world.isRemote) { - if(id == blockID) + if (id == blockID) { - TileEntityBattery battery = (TileEntityBattery)world.getBlockTileEntity(x, y, z); - + TileEntityBattery battery = (TileEntityBattery) world.getBlockTileEntity(x, y, z); + battery.update(); } } } - + @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) { - if(!world.isRemote) + if (!world.isRemote) { - TileEntityBattery battery = (TileEntityBattery)world.getBlockTileEntity(x, y, z); - + TileEntityBattery battery = (TileEntityBattery) world.getBlockTileEntity(x, y, z); + battery.update(); } } @@ -74,13 +76,13 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider { return false; } - + @Override public boolean isOpaqueCube() { return false; } - + @Override @SideOnly(Side.CLIENT) public int getRenderType() diff --git a/src/resonantinduction/contractor/BlockEMContractor.java b/src/resonantinduction/contractor/BlockEMContractor.java index 92ab5f3e..3cc9e6fe 100644 --- a/src/resonantinduction/contractor/BlockEMContractor.java +++ b/src/resonantinduction/contractor/BlockEMContractor.java @@ -20,7 +20,7 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider { public BlockEMContractor(int id) { - super("contractor", id, Material.iron); + super("contractor", id); this.func_111022_d(ResonantInduction.PREFIX + "machine"); } diff --git a/src/resonantinduction/multimeter/BlockMultimeter.java b/src/resonantinduction/multimeter/BlockMultimeter.java index 48cb2c6e..bc07ee0c 100644 --- a/src/resonantinduction/multimeter/BlockMultimeter.java +++ b/src/resonantinduction/multimeter/BlockMultimeter.java @@ -30,7 +30,7 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider public BlockMultimeter(int id) { - super("multimeter", id, Material.iron); + super("multimeter", id); } public static int determineOrientation(World par0World, int par1, int par2, int par3, EntityLivingBase par4EntityLivingBase) diff --git a/src/resonantinduction/tesla/BlockTesla.java b/src/resonantinduction/tesla/BlockTesla.java index 6a687c6b..17245e36 100644 --- a/src/resonantinduction/tesla/BlockTesla.java +++ b/src/resonantinduction/tesla/BlockTesla.java @@ -23,7 +23,7 @@ public class BlockTesla extends BlockBase implements ITileEntityProvider { public BlockTesla(int id) { - super("tesla", id, Material.iron); + super("tesla", id); this.func_111022_d(ResonantInduction.PREFIX + "machine"); } diff --git a/src/resonantinduction/tesla/TileEntityTesla.java b/src/resonantinduction/tesla/TileEntityTesla.java index 49df6c62..188d86ee 100644 --- a/src/resonantinduction/tesla/TileEntityTesla.java +++ b/src/resonantinduction/tesla/TileEntityTesla.java @@ -168,17 +168,14 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe if (this.attackEntities && this.zapCounter % 5 == 0) { - double[] rotations = topTeslaVector.difference(targetVector).normalize().getDeltaRotationFromPosition(); - MovingObjectPosition mop = topTeslaVector.rayTraceEntities(this.worldObj, rotations[0], rotations[1], distance); - // System.out.println(Vector3.getDeltaPositionFromRotation(rotations[0], - // rotations[1]) + " :" + mop); + MovingObjectPosition mop = topTeslaVector.clone().translate(0.5).rayTraceEntities(this.worldObj, targetVector.clone().translate(0.5)); if (mop != null && mop.entityHit != null) { if (mop.entityHit instanceof EntityLivingBase) { - mop.entityHit.attackEntityFrom(DamageSource.magic, 1); - ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), new Vector3(mop.entityHit)); + mop.entityHit.attackEntityFrom(DamageSource.magic, 3); + ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).clone().translate(0.5), new Vector3(mop.entityHit)); } } } @@ -269,7 +266,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe @Override public Packet getDescriptionPacket() { - return PacketHandler.getTileEntityPacket(this, (byte) 1, this.getEnergyStored(), this.dyeID, this.canReceive); + return PacketHandler.getTileEntityPacket(this, (byte) 1, this.getEnergyStored(), this.dyeID, this.canReceive, this.attackEntities); } @Override @@ -289,6 +286,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe this.energy = input.readFloat(); this.dyeID = input.readInt(); this.canReceive = input.readBoolean(); + this.attackEntities = input.readBoolean(); break; }