diff --git a/src/common/assemblyline/machines/BlockInteraction.java b/src/common/assemblyline/machines/BlockInteraction.java index 0edf24f9a..dd897b32c 100644 --- a/src/common/assemblyline/machines/BlockInteraction.java +++ b/src/common/assemblyline/machines/BlockInteraction.java @@ -124,7 +124,17 @@ public class BlockInteraction extends BlockMachine @Override public boolean onSneakUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer) { - return this.onUseWrench(par1World, x, y, z, par5EntityPlayer); + int metadata = par1World.getBlockMetadata(x, y, z); + + if(MachineType.getBase(metadata) == MachineType.MANIPULATOR) + { + ((TileEntityManipulator)par1World.getBlockTileEntity(x, y, z)).isWrenchedToOutput = !((TileEntityManipulator)par1World.getBlockTileEntity(x, y, z)).isWrenchedToOutput; + return true; + } + else + { + return this.onUseWrench(par1World, x, y, z, par5EntityPlayer); + } } @Override diff --git a/src/common/assemblyline/machines/TileEntityManipulator.java b/src/common/assemblyline/machines/TileEntityManipulator.java index 75588c6ce..25d4359cd 100644 --- a/src/common/assemblyline/machines/TileEntityManipulator.java +++ b/src/common/assemblyline/machines/TileEntityManipulator.java @@ -8,11 +8,13 @@ import net.minecraft.src.EntityPlayer; import net.minecraft.src.IInventory; import net.minecraft.src.INetworkManager; import net.minecraft.src.ItemStack; +import net.minecraft.src.NBTTagCompound; import net.minecraft.src.Packet250CustomPayload; import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntityChest; import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.Vector3; +import universalelectricity.electricity.ElectricInfo; import universalelectricity.prefab.TileEntityElectricityReceiver; import universalelectricity.prefab.network.IPacketReceiver; @@ -31,6 +33,11 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver * The amount of watts received. */ public double wattsReceived = 0; + + /** + * Is the manipulator wrenched to turn into output mode? + */ + public boolean isWrenchedToOutput = false; @Override public double wattRequest() @@ -162,7 +169,7 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver */ public boolean isOutput() { - return this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord) || this.worldObj.isBlockGettingPowered(this.xCoord, this.yCoord, this.zCoord); + return this.isWrenchedToOutput || this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord) || this.worldObj.isBlockGettingPowered(this.xCoord, this.yCoord, this.zCoord); } public ForgeDirection getBeltDirection() @@ -179,6 +186,23 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver @Override public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side) { - this.wattsReceived += (amps * voltage); + this.wattsReceived += ElectricInfo.getWatts(amps, voltage); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + nbt.setBoolean("isWrenchedToOutput", this.isWrenchedToOutput); + } + + /** + * Writes a tile entity to NBT. + */ + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + this.isWrenchedToOutput = nbt.getBoolean("isWrenchedToOutput"); } }