From 6b94b4d05a32c1d195aecc0ae6c7f7bc701bc125 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Sat, 3 Aug 2013 21:09:49 -0400 Subject: [PATCH] Polished off Contractor, just need to finish energy usage. --- .../contractor/TileEntityEMContractor.java | 36 ++++++++++++------- .../model/ModelEMContractor.java | 5 ++- .../render/RenderEMContractor.java | 2 +- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/resonantinduction/contractor/TileEntityEMContractor.java b/src/resonantinduction/contractor/TileEntityEMContractor.java index a33a97c3..b9d9259f 100644 --- a/src/resonantinduction/contractor/TileEntityEMContractor.java +++ b/src/resonantinduction/contractor/TileEntityEMContractor.java @@ -27,8 +27,8 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive { public static int MAX_REACH = 40; public static int PUSH_DELAY = 5; - public static double MAX_SPEED = .1; - public static double ACCELERATION = .01; + public static double MAX_SPEED = .2; + public static double ACCELERATION = .02; public static float ENERGY_USAGE = .005F; private ForgeDirection facing = ForgeDirection.UP; @@ -50,7 +50,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive { pushDelay = Math.max(0, pushDelay - 1); - if (isLatched() && canFunction()) + if (canFunction()) { TileEntity inventoryTile = getLatched(); IInventory inventory = (IInventory) inventoryTile; @@ -248,7 +248,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive } else { - entityItem.motionY = Math.min((MAX_SPEED * 4), entityItem.motionY + (ACCELERATION * 5)); + entityItem.motionY = Math.min(MAX_SPEED, entityItem.motionY + .04 + ACCELERATION); } entityItem.isAirBorne = true; @@ -264,7 +264,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive if (!suck) { - entityItem.motionY = Math.min((MAX_SPEED * 4), entityItem.motionY + (ACCELERATION * 5)); + entityItem.motionY = Math.min(MAX_SPEED, entityItem.motionY + .04 + ACCELERATION); } else { @@ -366,24 +366,26 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive switch (facing) { case DOWN: - item = new EntityItem(worldObj, xCoord + 0.5, yCoord, zCoord + 0.5, toSend); + item = new EntityItem(worldObj, xCoord + 0.5, yCoord - 0.2, 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.2, 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 - 0.2, 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.2, toSend); break; case WEST: - item = new EntityItem(worldObj, xCoord, yCoord + 0.5, zCoord + 0.5, toSend); + item = new EntityItem(worldObj, xCoord - 0.2, 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.2, yCoord + 0.5, zCoord + 0.5, toSend); break; } + + item.setVelocity(0, 0, 0); return item; } @@ -474,7 +476,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive public boolean canFunction() { - return worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) > 0; + return isLatched() && worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) > 0; } @Override @@ -484,6 +486,9 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive facing = ForgeDirection.getOrientation(nbtTags.getInteger("facing")); suck = nbtTags.getBoolean("suck"); + energyStored = nbtTags.getFloat("energyStored"); + + updateBounds(); } @Override @@ -493,6 +498,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive nbtTags.setInteger("facing", facing.ordinal()); nbtTags.setBoolean("suck", suck); + nbtTags.setFloat("energyStored", energyStored); } @Override @@ -502,6 +508,8 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive { facing = ForgeDirection.getOrientation(input.readInt()); suck = input.readBoolean(); + energyStored = input.readFloat(); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); updateBounds(); } @@ -515,6 +523,8 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive { data.add(facing.ordinal()); data.add(suck); + data.add(energyStored); + return data; } @@ -523,7 +533,7 @@ public class TileEntityEMContractor extends TileEntity implements IPacketReceive { float energyToUse = Math.min(transferEnergy, ENERGY_USAGE-energyStored); - if(doTransfer) + if (doTransfer) { energyStored += energyToUse; } diff --git a/src/resonantinduction/model/ModelEMContractor.java b/src/resonantinduction/model/ModelEMContractor.java index 41fe2727..60f5d23a 100644 --- a/src/resonantinduction/model/ModelEMContractor.java +++ b/src/resonantinduction/model/ModelEMContractor.java @@ -227,7 +227,10 @@ public class ModelEMContractor extends ModelBase { if(rotate) { - teslapole.rotateAngleY = (float)Math.toRadians(Math.toDegrees(teslapole.rotateAngleY)+4 < 360 ? Math.toDegrees(teslapole.rotateAngleY)+4 : 0); + Coil1.rotateAngleY = (float)Math.toRadians(Math.toDegrees(Coil1.rotateAngleY)+3 < 360 ? Math.toDegrees(Coil1.rotateAngleY)+3 : 0); + coil2.rotateAngleY = (float)Math.toRadians(Math.toDegrees(coil2.rotateAngleY)+3 < 360 ? Math.toDegrees(coil2.rotateAngleY)+3 : 0); + coil3.rotateAngleY = (float)Math.toRadians(Math.toDegrees(coil3.rotateAngleY)+3 < 360 ? Math.toDegrees(coil3.rotateAngleY)+3 : 0); + coil4.rotateAngleY = (float)Math.toRadians(Math.toDegrees(coil4.rotateAngleY)+3 < 360 ? Math.toDegrees(coil4.rotateAngleY)+3 : 0); } frame1.render(f5); diff --git a/src/resonantinduction/render/RenderEMContractor.java b/src/resonantinduction/render/RenderEMContractor.java index 5b538d23..1702d785 100644 --- a/src/resonantinduction/render/RenderEMContractor.java +++ b/src/resonantinduction/render/RenderEMContractor.java @@ -59,7 +59,7 @@ public class RenderEMContractor extends TileEntitySpecialRenderer this.func_110628_a(TEXTURE_PUSH); } - MODEL.render(0.0625f, true); + MODEL.render(0.0625f, ((TileEntityEMContractor)t).canFunction()); GL11.glPopMatrix(); }