diff --git a/resources/assets/resonantinduction/textures/items/linker.png b/resources/assets/resonantinduction/textures/items/linker.png index 2302f185..dd007045 100644 Binary files a/resources/assets/resonantinduction/textures/items/linker.png and b/resources/assets/resonantinduction/textures/items/linker.png differ diff --git a/src/resonantinduction/base/Vector3.java b/src/resonantinduction/base/Vector3.java index c61ac8f0..8a3d6f82 100644 --- a/src/resonantinduction/base/Vector3.java +++ b/src/resonantinduction/base/Vector3.java @@ -244,20 +244,21 @@ public class Vector3 return world.getBlockTileEntity((int) this.x, (int) this.y, (int) this.z); } - public MovingObjectPosition rayTraceEntities(World world, double rotationYaw, double rotationPitch, double reachDistance) + public MovingObjectPosition rayTraceEntities(World world, Vector3 target) { MovingObjectPosition pickedEntity = null; Vec3 startingPosition = this.toVec3(); - Vec3 look = getDeltaPositionFromRotation(rotationYaw, rotationPitch).toVec3(); + Vec3 look = target.normalize().toVec3(); + double reachDistance = this.distance(target); Vec3 reachPoint = Vec3.createVectorHelper(startingPosition.xCoord + look.xCoord * reachDistance, startingPosition.yCoord + look.yCoord * reachDistance, startingPosition.zCoord + look.zCoord * reachDistance); double checkBorder = 1.1 * reachDistance; AxisAlignedBB boxToScan = AxisAlignedBB.getAABBPool().getAABB(-checkBorder, -checkBorder, -checkBorder, checkBorder, checkBorder, checkBorder).offset(this.x, this.y, this.z); - ; @SuppressWarnings("unchecked") List 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; }