From 32cbb970f4e1c74c2e332682d0efc3cef4d51667 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sat, 3 Aug 2013 19:19:20 -0400 Subject: [PATCH] Added multimeter, no OP --- .../textures/blocks/multimeter.png | Bin 0 -> 2138 bytes .../textures/items/multimeter.png | Bin 0 -> 752 bytes src/resonantinduction/ITesla.java | 18 - src/resonantinduction/PacketHandler.java | 13 +- src/resonantinduction/ResonantInduction.java | 9 +- src/resonantinduction/api/ITesla.java | 23 ++ .../base/IPacketReceiver.java | 4 +- src/resonantinduction/base/Vector3.java | 5 +- .../contractor/BlockEMContractor.java | 38 +- .../contractor/ItemBlockContractor.java | 54 +-- .../contractor/TileEntityEMContractor.java | 390 +++++++++--------- .../entangler/ItemQuantumEntangler.java | 2 - src/resonantinduction/fx/FXElectricBolt.java | 6 +- .../multimeter/BlockMultimeter.java | 22 + .../render/RenderEMContractor.java | 15 +- src/resonantinduction/tesla/TeslaGrid.java | 2 +- .../tesla/TileEntityTesla.java | 26 +- 17 files changed, 338 insertions(+), 289 deletions(-) create mode 100644 resources/assets/resonantinduction/textures/blocks/multimeter.png create mode 100644 resources/assets/resonantinduction/textures/items/multimeter.png delete mode 100644 src/resonantinduction/ITesla.java create mode 100644 src/resonantinduction/api/ITesla.java create mode 100644 src/resonantinduction/multimeter/BlockMultimeter.java diff --git a/resources/assets/resonantinduction/textures/blocks/multimeter.png b/resources/assets/resonantinduction/textures/blocks/multimeter.png new file mode 100644 index 0000000000000000000000000000000000000000..36cd83f3d48f4bc3d9e9cae541fb0fc09e00ead8 GIT binary patch literal 2138 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 i8zY~Y^8|Q!1pWd@?(Sk<%|z4y0000 entitiesHit = world.getEntitiesWithinAABBExcludingEntity(null, boxToScan); double closestEntity = reachDistance; diff --git a/src/resonantinduction/contractor/BlockEMContractor.java b/src/resonantinduction/contractor/BlockEMContractor.java index dd4f9389..02287e63 100644 --- a/src/resonantinduction/contractor/BlockEMContractor.java +++ b/src/resonantinduction/contractor/BlockEMContractor.java @@ -2,12 +2,9 @@ package resonantinduction.contractor; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import resonantinduction.ResonantInduction; @@ -18,7 +15,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class BlockEMContractor extends BlockBase implements ITileEntityProvider { - public BlockEMContractor(int id) + public BlockEMContractor(int id) { super("contractor", id, Material.iron); this.func_111022_d(ResonantInduction.PREFIX + "machine"); @@ -30,35 +27,36 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider { return BlockRenderingHandler.INSTANCE.getRenderId(); } - + @Override public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) - { - TileEntityEMContractor contractor = (TileEntityEMContractor)par1World.getBlockTileEntity(par2, par3, par4); - - if(!par5EntityPlayer.isSneaking()) + { + TileEntityEMContractor contractor = (TileEntityEMContractor) par1World.getBlockTileEntity(par2, par3, par4); + + if (!par5EntityPlayer.isSneaking()) { contractor.incrementFacing(); } - else { + else + { contractor.suck = !contractor.suck; } - + return true; - } - + } + @Override public void onNeighborBlockChange(World world, int x, int y, int z, int blockID) { - TileEntityEMContractor tileContractor = (TileEntityEMContractor)world.getBlockTileEntity(x, y, z); - - if(!world.isRemote && !tileContractor.isLatched()) + TileEntityEMContractor tileContractor = (TileEntityEMContractor) world.getBlockTileEntity(x, y, z); + + if (!world.isRemote && !tileContractor.isLatched()) { - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - TileEntity tileEntity = world.getBlockTileEntity(x+side.offsetX, y+side.offsetY, z+side.offsetZ); - - if(tileEntity instanceof IInventory) + TileEntity tileEntity = world.getBlockTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ); + + if (tileEntity instanceof IInventory) { tileContractor.setFacing(side.getOpposite()); return; diff --git a/src/resonantinduction/contractor/ItemBlockContractor.java b/src/resonantinduction/contractor/ItemBlockContractor.java index 9ca49d3e..bb4233e7 100644 --- a/src/resonantinduction/contractor/ItemBlockContractor.java +++ b/src/resonantinduction/contractor/ItemBlockContractor.java @@ -10,36 +10,36 @@ import net.minecraftforge.common.ForgeDirection; public class ItemBlockContractor extends ItemBlock { - public ItemBlockContractor(int id) + public ItemBlockContractor(int id) { super(id); } - + @Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); - - if(place) - { - TileEntityEMContractor tileContractor = (TileEntityEMContractor)world.getBlockTileEntity(x, y, z); - tileContractor.setFacing(ForgeDirection.getOrientation(side)); - - if(!tileContractor.isLatched()) - { - for(ForgeDirection side1 : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tileEntity = world.getBlockTileEntity(x+side1.offsetX, y+side1.offsetY, z+side1.offsetZ); - - if(tileEntity instanceof IInventory) - { - tileContractor.setFacing(side1.getOpposite()); - break; - } - } - } - } - - return place; - } + { + boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + + if (place) + { + TileEntityEMContractor tileContractor = (TileEntityEMContractor) world.getBlockTileEntity(x, y, z); + tileContractor.setFacing(ForgeDirection.getOrientation(side)); + + if (!tileContractor.isLatched()) + { + for (ForgeDirection side1 : ForgeDirection.VALID_DIRECTIONS) + { + TileEntity tileEntity = world.getBlockTileEntity(x + side1.offsetX, y + side1.offsetY, z + side1.offsetZ); + + if (tileEntity instanceof IInventory) + { + tileContractor.setFacing(side1.getOpposite()); + break; + } + } + } + } + + return place; + } } diff --git a/src/resonantinduction/contractor/TileEntityEMContractor.java b/src/resonantinduction/contractor/TileEntityEMContractor.java index 99e09260..a529ddbf 100644 --- a/src/resonantinduction/contractor/TileEntityEMContractor.java +++ b/src/resonantinduction/contractor/TileEntityEMContractor.java @@ -23,81 +23,82 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive public static int PUSH_DELAY = 5; public static double MAX_SPEED = .1; public static double ACCELERATION = .01; - + private ForgeDirection facing = ForgeDirection.UP; - + public int pushDelay; - + public AxisAlignedBB operationBounds; public AxisAlignedBB suckBounds; - + /** * true = suck, false = push */ public boolean suck = true; - + @Override public void updateEntity() { - pushDelay = Math.max(0, pushDelay-1); - - if(isLatched()) + pushDelay = Math.max(0, pushDelay - 1); + + if (isLatched()) { TileEntity inventoryTile = getLatched(); - IInventory inventory = (IInventory)inventoryTile; - - if(!suck && pushDelay == 0) + IInventory inventory = (IInventory) inventoryTile; + + if (!suck && pushDelay == 0) { - if(!(inventoryTile instanceof ISidedInventory)) + if (!(inventoryTile instanceof ISidedInventory)) { - for(int i = inventory.getSizeInventory()-1; i >= 0; i--) + for (int i = inventory.getSizeInventory() - 1; i >= 0; i--) { - if(inventory.getStackInSlot(i) != null) + if (inventory.getStackInSlot(i) != null) { ItemStack toSend = inventory.getStackInSlot(i).copy(); toSend.stackSize = 1; - + EntityItem item = getItemWithPosition(toSend); - - if(!worldObj.isRemote) + + if (!worldObj.isRemote) { worldObj.spawnEntityInWorld(item); } - + inventory.decrStackSize(i, 1); pushDelay = PUSH_DELAY; - + break; } } } - else { - ISidedInventory sidedInventory = (ISidedInventory)inventoryTile; + else + { + ISidedInventory sidedInventory = (ISidedInventory) inventoryTile; int[] slots = sidedInventory.getAccessibleSlotsFromSide(facing.ordinal()); - - if(slots != null) + + if (slots != null) { - for(int get = slots.length-1; get >= 0; get--) + for (int get = slots.length - 1; get >= 0; get--) { int slotID = slots[get]; - - if(sidedInventory.getStackInSlot(slotID) != null) + + if (sidedInventory.getStackInSlot(slotID) != null) { ItemStack toSend = sidedInventory.getStackInSlot(slotID); toSend.stackSize = 1; - - if(sidedInventory.canExtractItem(slotID, toSend, facing.ordinal())) + + if (sidedInventory.canExtractItem(slotID, toSend, facing.ordinal())) { EntityItem item = getItemWithPosition(toSend); - - if(!worldObj.isRemote) + + if (!worldObj.isRemote) { worldObj.spawnEntityInWorld(item); } - + sidedInventory.decrStackSize(slotID, 1); pushDelay = PUSH_DELAY; - + break; } } @@ -105,50 +106,51 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive } } } - else if(suck) + else if (suck) { - if(suckBounds != null) + if (suckBounds != null) { List list = worldObj.getEntitiesWithinAABB(EntityItem.class, suckBounds); - - for(EntityItem item : list) + + for (EntityItem item : list) { ItemStack itemStack = item.getEntityItem(); - - if(!(inventoryTile instanceof ISidedInventory)) + + if (!(inventoryTile instanceof ISidedInventory)) { - for(int i = 0; i <= inventory.getSizeInventory()-1; i++) + for (int i = 0; i <= inventory.getSizeInventory() - 1; i++) { - if(inventory.isItemValidForSlot(i, itemStack)) + if (inventory.isItemValidForSlot(i, itemStack)) { ItemStack inSlot = inventory.getStackInSlot(i); - - if(inSlot == null) + + if (inSlot == null) { inventory.setInventorySlotContents(i, itemStack); item.setDead(); break; } - else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) + else if (inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) { - if(inSlot.stackSize+itemStack.stackSize <= inSlot.getMaxStackSize()) + if (inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize()) { ItemStack toSet = itemStack.copy(); - toSet.stackSize+=inSlot.stackSize; - + toSet.stackSize += inSlot.stackSize; + inventory.setInventorySlotContents(i, toSet); item.setDead(); break; } - else { - int rejects = (inSlot.stackSize+itemStack.stackSize) - inSlot.getMaxStackSize(); - + else + { + int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize(); + ItemStack toSet = itemStack.copy(); toSet.stackSize = inSlot.getMaxStackSize(); - + ItemStack remains = itemStack.copy(); remains.stackSize = rejects; - + inventory.setInventorySlotContents(i, toSet); item.setEntityItemStack(remains); } @@ -156,44 +158,46 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive } } } - else { - ISidedInventory sidedInventory = (ISidedInventory)inventoryTile; + else + { + ISidedInventory sidedInventory = (ISidedInventory) inventoryTile; int[] slots = sidedInventory.getAccessibleSlotsFromSide(facing.ordinal()); - - for(int get = 0; get <= slots.length-1; get++) + + for (int get = 0; get <= slots.length - 1; get++) { int slotID = slots[get]; - - if(sidedInventory.isItemValidForSlot(slotID, itemStack) && sidedInventory.canInsertItem(slotID, itemStack, facing.ordinal())) + + if (sidedInventory.isItemValidForSlot(slotID, itemStack) && sidedInventory.canInsertItem(slotID, itemStack, facing.ordinal())) { ItemStack inSlot = inventory.getStackInSlot(slotID); - - if(inSlot == null) + + if (inSlot == null) { inventory.setInventorySlotContents(slotID, itemStack); item.setDead(); break; } - else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) + else if (inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) { - if(inSlot.stackSize+itemStack.stackSize <= inSlot.getMaxStackSize()) + if (inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize()) { ItemStack toSet = itemStack.copy(); - toSet.stackSize+=inSlot.stackSize; - + toSet.stackSize += inSlot.stackSize; + inventory.setInventorySlotContents(slotID, toSet); item.setDead(); break; } - else { - int rejects = (inSlot.stackSize+itemStack.stackSize) - inSlot.getMaxStackSize(); - + else + { + int rejects = (inSlot.stackSize + itemStack.stackSize) - inSlot.getMaxStackSize(); + ItemStack toSet = itemStack.copy(); toSet.stackSize = inSlot.getMaxStackSize(); - + ItemStack remains = itemStack.copy(); remains.stackSize = rejects; - + inventory.setInventorySlotContents(slotID, toSet); item.setEntityItemStack(remains); } @@ -205,131 +209,137 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive } } } - - if(operationBounds != null) + + if (operationBounds != null) { List list = worldObj.getEntitiesWithinAABB(Entity.class, operationBounds); - - for(Entity entity : list) + + for (Entity entity : list) { - if(entity instanceof EntityItem) + if (entity instanceof EntityItem) { - EntityItem entityItem = (EntityItem)entity; - - switch(facing) + EntityItem entityItem = (EntityItem) entity; + + switch (facing) { case DOWN: - if(!worldObj.isRemote) + if (!worldObj.isRemote) { - entityItem.setPosition(xCoord+0.5, entityItem.posY, zCoord+0.5); + entityItem.setPosition(xCoord + 0.5, entityItem.posY, zCoord + 0.5); } - + entityItem.motionX = 0; entityItem.motionZ = 0; - - if(!suck) + + if (!suck) { - entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY-ACCELERATION); + entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY - ACCELERATION); } - else { - entityItem.motionY = Math.min((MAX_SPEED*4), entityItem.motionY+(ACCELERATION*5)); + else + { + entityItem.motionY = Math.min((MAX_SPEED * 4), entityItem.motionY + (ACCELERATION * 5)); } - + entityItem.isAirBorne = true; break; case UP: - if(!worldObj.isRemote) + if (!worldObj.isRemote) { - entityItem.setPosition(xCoord+0.5, entityItem.posY, zCoord+0.5); + entityItem.setPosition(xCoord + 0.5, entityItem.posY, zCoord + 0.5); } - + entityItem.motionX = 0; entityItem.motionZ = 0; - - if(!suck) + + if (!suck) { - entityItem.motionY = Math.min((MAX_SPEED*4), entityItem.motionY+(ACCELERATION*5)); + entityItem.motionY = Math.min((MAX_SPEED * 4), entityItem.motionY + (ACCELERATION * 5)); } - else { - entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY-ACCELERATION); + else + { + entityItem.motionY = Math.max(-MAX_SPEED, entityItem.motionY - ACCELERATION); } - + entityItem.isAirBorne = true; break; case NORTH: - if(!worldObj.isRemote) + if (!worldObj.isRemote) { - entityItem.setPosition(xCoord+0.5, yCoord+0.5, entityItem.posZ); + entityItem.setPosition(xCoord + 0.5, yCoord + 0.5, entityItem.posZ); } - + entityItem.motionX = 0; entityItem.motionY = 0; - - if(!suck) + + if (!suck) { - entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ-ACCELERATION); + entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ - ACCELERATION); } - else { - entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ+ACCELERATION); + else + { + entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ + ACCELERATION); } - + entityItem.isAirBorne = true; break; case SOUTH: - if(!worldObj.isRemote) + if (!worldObj.isRemote) { - entityItem.setPosition(xCoord+0.5, yCoord+0.5, entityItem.posZ); + entityItem.setPosition(xCoord + 0.5, yCoord + 0.5, entityItem.posZ); } - + entityItem.motionX = 0; entityItem.motionY = 0; - - if(!suck) + + if (!suck) { - entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ+ACCELERATION); + entityItem.motionZ = Math.min(MAX_SPEED, entityItem.motionZ + ACCELERATION); } - else { - entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ-ACCELERATION); + else + { + entityItem.motionZ = Math.max(-MAX_SPEED, entityItem.motionZ - ACCELERATION); } - + entityItem.isAirBorne = true; break; case WEST: - if(!worldObj.isRemote) + if (!worldObj.isRemote) { - entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5); + entityItem.setPosition(entityItem.posX, yCoord + 0.5, zCoord + 0.5); } - + entityItem.motionY = 0; entityItem.motionZ = 0; - - if(!suck) + + if (!suck) { - entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX-ACCELERATION); + entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX - ACCELERATION); } - else { - entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX+ACCELERATION); + else + { + entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX + ACCELERATION); } - + entityItem.isAirBorne = true; break; case EAST: - if(!worldObj.isRemote) + if (!worldObj.isRemote) { - entityItem.setPosition(entityItem.posX, yCoord+0.5, zCoord+0.5); + entityItem.setPosition(entityItem.posX, yCoord + 0.5, zCoord + 0.5); } - + entityItem.motionY = 0; entityItem.motionZ = 0; - - if(!suck) + + if (!suck) { - entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX+ACCELERATION); + entityItem.motionX = Math.min(MAX_SPEED, entityItem.motionX + ACCELERATION); } - else { - entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX-ACCELERATION); + else + { + entityItem.motionX = Math.max(-MAX_SPEED, entityItem.motionX - ACCELERATION); } - + entityItem.isAirBorne = true; break; } @@ -337,147 +347,151 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive } } } - + private EntityItem getItemWithPosition(ItemStack toSend) { EntityItem item = null; - - switch(facing) + + switch (facing) { case DOWN: - item = new EntityItem(worldObj, xCoord+0.5, yCoord, zCoord+0.5, toSend); + item = new EntityItem(worldObj, xCoord + 0.5, yCoord, zCoord + 0.5, toSend); break; case UP: - item = new EntityItem(worldObj, xCoord+0.5, yCoord+1, zCoord+0.5, toSend); + item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, toSend); break; case NORTH: - item = new EntityItem(worldObj, xCoord+0.5, yCoord+0.5, zCoord, toSend); + item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord, toSend); break; case SOUTH: - item = new EntityItem(worldObj, xCoord+0.5, yCoord+0.5, zCoord+1, toSend); + item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 1, toSend); break; case WEST: - item = new EntityItem(worldObj, xCoord, yCoord+0.5, zCoord+0.5, toSend); + item = new EntityItem(worldObj, xCoord, yCoord + 0.5, zCoord + 0.5, toSend); break; case EAST: - item = new EntityItem(worldObj, xCoord+1, yCoord+0.5, zCoord+0.5, toSend); + item = new EntityItem(worldObj, xCoord + 1, yCoord + 0.5, zCoord + 0.5, toSend); break; } - + return item; } - + @Override public void validate() { super.validate(); - - if(worldObj.isRemote) + + if (worldObj.isRemote) { PacketHandler.sendDataRequest(this); } } - + public void updateBounds() { - switch(facing) + switch (facing) { case DOWN: - operationBounds = AxisAlignedBB.getBoundingBox(xCoord, Math.max(yCoord-MAX_REACH, 1), zCoord, xCoord+1, yCoord, zCoord+1); - suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord-0.1, zCoord, xCoord+1, yCoord, zCoord+1); + operationBounds = AxisAlignedBB.getBoundingBox(xCoord, Math.max(yCoord - MAX_REACH, 1), zCoord, xCoord + 1, yCoord, zCoord + 1); + suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord - 0.1, zCoord, xCoord + 1, yCoord, zCoord + 1); break; case UP: - operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord+1, zCoord, xCoord+1, Math.min(yCoord+1+MAX_REACH, 255), zCoord+1); - suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord+1, zCoord, xCoord+1, yCoord+1.1, zCoord+1); + operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, Math.min(yCoord + 1 + MAX_REACH, 255), zCoord + 1); + suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 1.1, zCoord + 1); break; case NORTH: - operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord-MAX_REACH, xCoord+1, yCoord+1, zCoord); - suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord-0.1, xCoord+1, yCoord+1, zCoord); + operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord - MAX_REACH, xCoord + 1, yCoord + 1, zCoord); + suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord - 0.1, xCoord + 1, yCoord + 1, zCoord); break; case SOUTH: - operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord+1, xCoord+1, yCoord+1, zCoord+1+MAX_REACH); - suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord+1, xCoord+1, yCoord+1, zCoord+1.1); + operationBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord + 1, xCoord + 1, yCoord + 1, zCoord + 1 + MAX_REACH); + suckBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord + 1, xCoord + 1, yCoord + 1, zCoord + 1.1); break; case WEST: - operationBounds = AxisAlignedBB.getBoundingBox(xCoord-MAX_REACH, yCoord, zCoord, xCoord, yCoord+1, zCoord+1); - suckBounds = AxisAlignedBB.getBoundingBox(xCoord-0.1, yCoord, zCoord, xCoord, yCoord+1, zCoord+1); + operationBounds = AxisAlignedBB.getBoundingBox(xCoord - MAX_REACH, yCoord, zCoord, xCoord, yCoord + 1, zCoord + 1); + suckBounds = AxisAlignedBB.getBoundingBox(xCoord - 0.1, yCoord, zCoord, xCoord, yCoord + 1, zCoord + 1); break; case EAST: - operationBounds = AxisAlignedBB.getBoundingBox(xCoord+1, yCoord, zCoord, xCoord+1+MAX_REACH, yCoord+1, zCoord+1); - suckBounds = AxisAlignedBB.getBoundingBox(xCoord+1, yCoord, zCoord, xCoord+1.1, yCoord+1, zCoord+1); + operationBounds = AxisAlignedBB.getBoundingBox(xCoord + 1, yCoord, zCoord, xCoord + 1 + MAX_REACH, yCoord + 1, zCoord + 1); + suckBounds = AxisAlignedBB.getBoundingBox(xCoord + 1, yCoord, zCoord, xCoord + 1.1, yCoord + 1, zCoord + 1); break; } } - + public boolean isLatched() { return getLatched() != null; } - + public TileEntity getLatched() { ForgeDirection side = facing.getOpposite(); - - TileEntity tile = worldObj.getBlockTileEntity(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ); - - if(tile instanceof IInventory) + + TileEntity tile = worldObj.getBlockTileEntity(xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ); + + if (tile instanceof IInventory) { return tile; } - + return null; } - + public void incrementFacing() { - int newOrdinal = facing.ordinal() < 5 ? facing.ordinal()+1 : 0; + int newOrdinal = facing.ordinal() < 5 ? facing.ordinal() + 1 : 0; setFacing(ForgeDirection.getOrientation(newOrdinal)); } - + public ForgeDirection getFacing() { return facing; } - + public void setFacing(ForgeDirection side) { facing = side; - - if(!worldObj.isRemote) + + if (!worldObj.isRemote) { PacketHandler.sendTileEntityPacketToClients(this, getNetworkedData(new ArrayList()).toArray()); } - + updateBounds(); } - + @Override - public void readFromNBT(NBTTagCompound nbtTags) - { + public void readFromNBT(NBTTagCompound nbtTags) + { super.readFromNBT(nbtTags); - + facing = ForgeDirection.getOrientation(nbtTags.getInteger("facing")); suck = nbtTags.getBoolean("suck"); - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("facing", facing.ordinal()); - nbtTags.setBoolean("suck", suck); - } + } @Override - public void handle(ByteArrayDataInput input) + public void writeToNBT(NBTTagCompound nbtTags) { - try { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("facing", facing.ordinal()); + nbtTags.setBoolean("suck", suck); + } + + @Override + public void handle(ByteArrayDataInput input) + { + try + { facing = ForgeDirection.getOrientation(input.readInt()); suck = input.readBoolean(); worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); updateBounds(); - } catch(Exception e) {} + } + catch (Exception e) + { + } } @Override diff --git a/src/resonantinduction/entangler/ItemQuantumEntangler.java b/src/resonantinduction/entangler/ItemQuantumEntangler.java index 9875c255..aad9d20c 100644 --- a/src/resonantinduction/entangler/ItemQuantumEntangler.java +++ b/src/resonantinduction/entangler/ItemQuantumEntangler.java @@ -2,13 +2,11 @@ package resonantinduction.entangler; import java.util.List; -import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import resonantinduction.ResonantInduction; import resonantinduction.base.ItemBase; import resonantinduction.base.Vector3; import cpw.mods.fml.relauncher.Side; diff --git a/src/resonantinduction/fx/FXElectricBolt.java b/src/resonantinduction/fx/FXElectricBolt.java index 0a6e1638..7a368689 100644 --- a/src/resonantinduction/fx/FXElectricBolt.java +++ b/src/resonantinduction/fx/FXElectricBolt.java @@ -154,7 +154,7 @@ public class FXElectricBolt extends EntityFX */ for (int i = 1; i < splitAmount; i++) { - Vector3 newOffset = segment.difference.getPerpendicular().rotate((float) (this.rand.nextFloat() * 180), segment.difference).scale((this.rand.nextFloat() - 0.5F) * offset); + Vector3 newOffset = segment.difference.getPerpendicular().rotate(this.rand.nextFloat() * 180, segment.difference).scale((this.rand.nextFloat() - 0.5F) * offset); Vector3 basePoint = startPoint.clone().translate(subSegment.clone().scale(i)); newPoints[i] = new BoltPoint(basePoint, newOffset); @@ -227,7 +227,7 @@ public class FXElectricBolt extends EntityFX { lastActiveSegment.put(lastSplitCalc, lastActiveSeg); lastSplitCalc = segment.splitID; - lastActiveSeg = ((Integer) lastActiveSegment.get(this.parentIDMap.get(segment.splitID))).intValue(); + lastActiveSeg = lastActiveSegment.get(this.parentIDMap.get(segment.splitID)).intValue(); } lastActiveSeg = segment.id; @@ -235,7 +235,7 @@ public class FXElectricBolt extends EntityFX lastActiveSegment.put(lastSplitCalc, lastActiveSeg); lastSplitCalc = 0; - lastActiveSeg = ((Integer) lastActiveSegment.get(0)).intValue(); + lastActiveSeg = lastActiveSegment.get(0).intValue(); BoltSegment segment; for (Iterator iterator = this.segments.iterator(); iterator.hasNext(); segment.recalculate()) diff --git a/src/resonantinduction/multimeter/BlockMultimeter.java b/src/resonantinduction/multimeter/BlockMultimeter.java new file mode 100644 index 00000000..9d7f9424 --- /dev/null +++ b/src/resonantinduction/multimeter/BlockMultimeter.java @@ -0,0 +1,22 @@ +/** + * + */ +package resonantinduction.multimeter; + +import net.minecraft.block.material.Material; +import resonantinduction.base.BlockBase; + +/** + * A block that detects power. + * + * @author Calclavia + * + */ +public class BlockMultimeter extends BlockBase +{ + public BlockMultimeter(int id) + { + super("multimeter", id, Material.iron); + } + +} diff --git a/src/resonantinduction/render/RenderEMContractor.java b/src/resonantinduction/render/RenderEMContractor.java index 2145d61b..eb9d56ac 100644 --- a/src/resonantinduction/render/RenderEMContractor.java +++ b/src/resonantinduction/render/RenderEMContractor.java @@ -15,7 +15,7 @@ public class RenderEMContractor extends TileEntitySpecialRenderer public static final ModelEMContractor MODEL = new ModelEMContractor(); public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "em_contractor.png"); public static final ResourceLocation TEXTURE_PUSH = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "em_contractor_push.png"); - + @Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f) { @@ -23,8 +23,8 @@ public class RenderEMContractor extends TileEntitySpecialRenderer GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - - switch(((TileEntityEMContractor)t).getFacing()) + + switch (((TileEntityEMContractor) t).getFacing()) { case DOWN: GL11.glRotatef(180, 0, 0, 1); @@ -49,15 +49,16 @@ public class RenderEMContractor extends TileEntitySpecialRenderer GL11.glRotatef(90, 1, 0, 0); break; } - - if(((TileEntityEMContractor)t).suck) + + if (((TileEntityEMContractor) t).suck) { this.func_110628_a(TEXTURE); } - else { + else + { this.func_110628_a(TEXTURE_PUSH); } - + MODEL.render(0.0625f); GL11.glPopMatrix(); diff --git a/src/resonantinduction/tesla/TeslaGrid.java b/src/resonantinduction/tesla/TeslaGrid.java index 64e8a3dc..93872a3e 100644 --- a/src/resonantinduction/tesla/TeslaGrid.java +++ b/src/resonantinduction/tesla/TeslaGrid.java @@ -8,7 +8,7 @@ import java.util.Iterator; import java.util.Set; import net.minecraft.tileentity.TileEntity; -import resonantinduction.ITesla; +import resonantinduction.api.ITesla; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; diff --git a/src/resonantinduction/tesla/TileEntityTesla.java b/src/resonantinduction/tesla/TileEntityTesla.java index 6bf36102..6572586d 100644 --- a/src/resonantinduction/tesla/TileEntityTesla.java +++ b/src/resonantinduction/tesla/TileEntityTesla.java @@ -17,12 +17,11 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.packet.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.MovingObjectPosition; -import resonantinduction.ITesla; import resonantinduction.PacketHandler; import resonantinduction.ResonantInduction; +import resonantinduction.api.ITesla; import resonantinduction.base.IPacketReceiver; import resonantinduction.base.TileEntityBase; import resonantinduction.base.Vector3; @@ -150,7 +149,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe { if (this.zapCounter % 5 == 0 && ResonantInduction.SOUND_FXS) { - this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", this.getEnergyStored() / 25, (float) (1.3f - 0.5f * ((float) this.dyeID / 16f))); + this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, ResonantInduction.PREFIX + "electricshock", this.getEnergyStored() / 25, 1.3f - 0.5f * (this.dyeID / 16f)); } Vector3 targetVector = new Vector3((TileEntity) tesla); @@ -164,8 +163,8 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe double distance = topTeslaVector.distance(targetVector); ResonantInduction.proxy.renderElectricShock(this.worldObj, new Vector3(topTesla).translate(new Vector3(0.5)), targetVector.translate(new Vector3(0.5)), (float) dyeColors[this.dyeID].x, (float) dyeColors[this.dyeID].y, (float) dyeColors[this.dyeID].z); - tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f))); - this.transfer(-transferEnergy); + tesla.transfer(transferEnergy * (1 - (this.worldObj.rand.nextFloat() * 0.1f)), true); + this.transfer(-transferEnergy, true); if (this.attackEntities && this.zapCounter % 5 == 0) { @@ -225,7 +224,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe } else { - this.transfer(ResonantInduction.POWER_PER_COAL / 20); + this.transfer(ResonantInduction.POWER_PER_COAL / 20, true); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } @@ -242,7 +241,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe boolean doBlockStateUpdate = furnaceTile.furnaceBurnTime > 0; furnaceTile.furnaceBurnTime += 2; - this.transfer(-ResonantInduction.POWER_PER_COAL / 20); + this.transfer(-ResonantInduction.POWER_PER_COAL / 20, true); this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); if (doBlockStateUpdate != furnaceTile.furnaceBurnTime > 0) @@ -314,17 +313,22 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe } @Override - public void transfer(float transferEnergy) + public float transfer(float transferEnergy, boolean doTransfer) { if (isController() || this.getControllingTelsa() == this) { - this.energy = Math.max(this.energy + transferEnergy, 0); + if (doTransfer) + { + this.energy = Math.max(this.energy + transferEnergy, 0); + } + this.doTransfer = true; this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + return transferEnergy; } else { - this.getControllingTelsa().transfer(transferEnergy); + return this.getControllingTelsa().transfer(transferEnergy, doTransfer); } } @@ -484,6 +488,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe /** * Reads a tile entity from NBT. */ + @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); @@ -495,6 +500,7 @@ public class TileEntityTesla extends TileEntityBase implements ITesla, IPacketRe /** * Writes a tile entity to NBT. */ + @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt);