Added wrenching ability to set to output

This commit is contained in:
Calclavia 2012-10-28 17:26:23 +08:00
parent edb4234ad0
commit a554b914bd
2 changed files with 37 additions and 3 deletions

View file

@ -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

View file

@ -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;
@ -32,6 +34,11 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver
*/
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");
}
}