Added lightning to EM Contractor

This commit is contained in:
Calclavia 2013-08-03 21:27:12 -04:00
parent 37d9200af2
commit 50fe6c44d0
2 changed files with 266 additions and 254 deletions

View file

@ -135,7 +135,7 @@ public class Vector3
return new Vector3(this.x + offset.x, this.y + offset.y, this.z + offset.z); return new Vector3(this.x + offset.x, this.y + offset.y, this.z + offset.z);
} }
public Vector3 translate(int offset) public Vector3 translate(double offset)
{ {
return new Vector3(this.x + offset, this.y + offset, this.z + offset); return new Vector3(this.x + offset, this.y + offset, this.z + offset);
} }

View file

@ -13,8 +13,11 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.PacketHandler; import resonantinduction.PacketHandler;
import resonantinduction.ResonantInduction;
import resonantinduction.api.ITesla; import resonantinduction.api.ITesla;
import resonantinduction.base.IPacketReceiver; import resonantinduction.base.IPacketReceiver;
import resonantinduction.base.TileEntityBase;
import resonantinduction.base.Vector3;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
@ -23,7 +26,7 @@ import com.google.common.io.ByteArrayDataInput;
* @author AidanBrady * @author AidanBrady
* *
*/ */
public class TileEntityEMContractor extends TileEntity implements IPacketReceiver, ITesla public class TileEntityEMContractor extends TileEntityBase implements IPacketReceiver, ITesla
{ {
public static int MAX_REACH = 40; public static int MAX_REACH = 40;
public static int PUSH_DELAY = 5; public static int PUSH_DELAY = 5;
@ -48,9 +51,12 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
@Override @Override
public void updateEntity() public void updateEntity()
{ {
pushDelay = Math.max(0, pushDelay - 1); super.updateEntity();
this.pushDelay = Math.max(0, pushDelay - 1);
if (isLatched() && canFunction()) if (canFunction())
{
if (isLatched())
{ {
TileEntity inventoryTile = getLatched(); TileEntity inventoryTile = getLatched();
IInventory inventory = (IInventory) inventoryTile; IInventory inventory = (IInventory) inventoryTile;
@ -219,7 +225,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
} }
} }
if (operationBounds != null && canFunction()) if (operationBounds != null)
{ {
List<Entity> list = worldObj.getEntitiesWithinAABB(Entity.class, operationBounds); List<Entity> list = worldObj.getEntitiesWithinAABB(Entity.class, operationBounds);
@ -231,6 +237,11 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
{ {
EntityItem entityItem = (EntityItem) entity; EntityItem entityItem = (EntityItem) entity;
if (this.worldObj.isRemote && this.ticks % 5 == 0)
{
ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(this).translate(0.5), new Vector3(entityItem));
}
switch (facing) switch (facing)
{ {
case DOWN: case DOWN:
@ -358,6 +369,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
} }
} }
} }
}
private EntityItem getItemWithPosition(ItemStack toSend) private EntityItem getItemWithPosition(ItemStack toSend)
{ {
@ -474,7 +486,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive
public boolean canFunction() public boolean canFunction()
{ {
return worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) > 0; return !this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord);
} }
@Override @Override