Fixed #144 - Armbot multiblock not placing

This commit is contained in:
Calclavia 2014-01-23 21:35:30 +08:00
parent 9d42e9e99d
commit d3535903ab
2 changed files with 425 additions and 424 deletions

View file

@ -69,6 +69,7 @@ public class BlockArmbot extends BlockRI implements IBlockInfo
((TileArmbot) tileEntity).dropHeldObject(); ((TileArmbot) tileEntity).dropHeldObject();
CalclaviaLoader.blockMulti.destroyMultiBlockStructure((TileArmbot) tileEntity); CalclaviaLoader.blockMulti.destroyMultiBlockStructure((TileArmbot) tileEntity);
} }
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(this)); this.dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
super.breakBlock(world, x, y, z, par5, par6); super.breakBlock(world, x, y, z, par5, par6);
} }

View file

@ -11,489 +11,489 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.api.IArmbot; import resonantinduction.api.IArmbot;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.prefab.tile.TileMachine;
import resonantinduction.electrical.Electrical;
import resonantinduction.electrical.armbot.task.TaskDrop; import resonantinduction.electrical.armbot.task.TaskDrop;
import resonantinduction.electrical.armbot.task.TaskGOTO; import resonantinduction.electrical.armbot.task.TaskGOTO;
import resonantinduction.electrical.armbot.task.TaskGrabItem; import resonantinduction.electrical.armbot.task.TaskGrabItem;
import resonantinduction.electrical.armbot.task.TaskReturn; import resonantinduction.electrical.armbot.task.TaskReturn;
import resonantinduction.electrical.armbot.task.TaskRotateTo; import resonantinduction.electrical.armbot.task.TaskRotateTo;
import resonantinduction.electrical.encoder.ItemDisk;
import resonantinduction.electrical.encoder.coding.IProgram; import resonantinduction.electrical.encoder.coding.IProgram;
import resonantinduction.electrical.encoder.coding.ProgramHelper; import resonantinduction.electrical.encoder.coding.ProgramHelper;
import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.api.vector.Vector2; import universalelectricity.api.vector.Vector2;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.multiblock.fake.IBlockActivate;
import calclavia.lib.multiblock.fake.IMultiBlock; import calclavia.lib.multiblock.fake.IMultiBlock;
import calclavia.lib.network.IPacketReceiverWithID;
import calclavia.lib.network.PacketHandler; import calclavia.lib.network.PacketHandler;
import calclavia.lib.utility.LanguageUtility; import calclavia.lib.prefab.tile.TileElectrical;
import calclavia.lib.utility.MathUtility; import calclavia.lib.utility.MathUtility;
import calclavia.lib.utility.WorldUtility; import calclavia.lib.utility.WorldUtility;
import com.builtbroken.common.Pair; import com.builtbroken.common.Pair;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.FMLCommonHandler; public class TileArmbot extends TileElectrical implements IMultiBlock, IArmbot, IPacketReceiverWithID
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.relauncher.Side;
public class TileArmbot extends TileMachine implements IMultiBlock, IArmbot
{ {
protected int ROTATION_SPEED = 6; protected int ROTATION_SPEED = 6;
/** The rotation of the arms. In Degrees. */ /** The rotation of the arms. In Degrees. */
protected int targetPitch = 0, targetYaw = 0; protected int targetPitch = 0, targetYaw = 0;
protected int actualPitch = 0, actualYaw = 0; protected int actualPitch = 0, actualYaw = 0;
protected boolean spawnEntity = false; protected boolean spawnEntity = false;
protected String displayText = ""; protected String displayText = "";
/** An entity that the Armbot is grabbed onto. Entity Items are held separately. */ /** An entity that the Armbot is grabbed onto. Entity Items are held separately. */
protected Object grabbedObject = null; protected Object grabbedObject = null;
/** Helper class that does all the logic for the armbot's program */ /** Helper class that does all the logic for the armbot's program */
protected ProgramHelper programHelper; protected ProgramHelper programHelper;
/** Cached location of the armbot to feed to program tasks */ /** Cached location of the armbot to feed to program tasks */
protected Pair<World, Vector3> location; protected Pair<World, Vector3> location;
/** Var used by the armbot renderer */ /** Var used by the armbot renderer */
public EntityItem renderEntityItem; public EntityItem renderEntityItem;
public static final int ARMBOT_PACKET_ID = 3; /**
public static final int ROTATION_PACKET_ID = 4; * Used client side only for render.
*/
private boolean functioning;
public TileArmbot() public static final int ARMBOT_PACKET_ID = 3;
{ public static final int ROTATION_PACKET_ID = 4;
this.joulesPerTick = 20;
programHelper = new ProgramHelper(this).setMemoryLimit(20);
Program program = new Program();
program.setTaskAt(0, 0, new TaskDrop());
program.setTaskAt(0, 1, new TaskRotateTo(180, 0));
program.setTaskAt(0, 2, new TaskGrabItem());
program.setTaskAt(0, 3, new TaskReturn());
program.setTaskAt(0, 4, new TaskGOTO(0, 0));
programHelper.setProgram(program);
}
/************************************ Armbot logic update methods *************************************/ public TileArmbot()
{
energy = new EnergyStorageHandler(5000, 1000);
programHelper = new ProgramHelper(this).setMemoryLimit(20);
Program program = new Program();
program.setTaskAt(0, 0, new TaskDrop());
program.setTaskAt(0, 1, new TaskRotateTo(180, 0));
program.setTaskAt(0, 2, new TaskGrabItem());
program.setTaskAt(0, 3, new TaskReturn());
program.setTaskAt(0, 4, new TaskGOTO(0, 0));
programHelper.setProgram(program);
}
@Override /************************************ Armbot logic update methods *************************************/
public void updateEntity()
{
super.updateEntity();
Vector3 handPosition = this.getHandPos();
if (this.location == null || !this.location.left().equals(this.worldObj) || this.xCoord != this.location.right().intX() || this.yCoord != this.location.right().intY() || this.zCoord != this.location.right().intZ())
{
this.location = new Pair<World, Vector3>(this.worldObj, new Vector3(this));
}
if (this.grabbedObject instanceof Entity)
{
if (this.spawnEntity)
{
this.worldObj.spawnEntityInWorld((Entity) this.grabbedObject);
this.spawnEntity = false;
}
((Entity) this.grabbedObject).setPosition(handPosition.x, handPosition.y, handPosition.z);
((Entity) this.grabbedObject).motionX = 0;
((Entity) this.grabbedObject).motionY = 0;
((Entity) this.grabbedObject).motionZ = 0;
if (this.grabbedObject instanceof EntityItem) @Override
{ public void updateEntity()
((EntityItem) this.grabbedObject).delayBeforeCanPickup = 20; {
((EntityItem) this.grabbedObject).age = 0; super.updateEntity();
} Vector3 handPosition = this.getHandPos();
} if (this.location == null || !this.location.left().equals(this.worldObj) || this.xCoord != this.location.right().intX() || this.yCoord != this.location.right().intY() || this.zCoord != this.location.right().intZ())
{
this.location = new Pair<World, Vector3>(this.worldObj, new Vector3(this));
}
if (this.grabbedObject instanceof Entity)
{
if (this.spawnEntity)
{
this.worldObj.spawnEntityInWorld((Entity) this.grabbedObject);
this.spawnEntity = false;
}
((Entity) this.grabbedObject).setPosition(handPosition.x, handPosition.y, handPosition.z);
((Entity) this.grabbedObject).motionX = 0;
((Entity) this.grabbedObject).motionY = 0;
((Entity) this.grabbedObject).motionZ = 0;
if (this.isFunctioning()) if (this.grabbedObject instanceof EntityItem)
{ {
float preYaw = this.targetYaw, prePitch = this.targetPitch; ((EntityItem) this.grabbedObject).delayBeforeCanPickup = 20;
if (!this.worldObj.isRemote && this.ticks % 5 == 0) ((EntityItem) this.grabbedObject).age = 0;
{ }
this.programHelper.onUpdate(this.worldObj, new Vector3(this)); }
if (this.targetYaw != preYaw || this.targetPitch != prePitch)
{
PacketHandler.sendPacketToClients(this.getDescriptionPacket(), worldObj, new Vector3(this).translate(new Vector3(.5f, 1f, .5f)), 64);
}
}
this.updateRotation();
}
}
public void updateRotation() if (energy.checkExtract())
{ {
// Clamp target angles float preYaw = this.targetYaw, prePitch = this.targetPitch;
this.targetYaw = (int) MathUtility.clampAngleTo360(this.targetYaw); if (!this.worldObj.isRemote && this.ticks % 5 == 0)
if (this.targetPitch < 0) {
this.targetPitch = 0; this.programHelper.onUpdate(this.worldObj, new Vector3(this));
if (this.targetPitch > 60) if (this.targetYaw != preYaw || this.targetPitch != prePitch)
this.targetPitch = 60; {
// Handle change in yaw rotation PacketHandler.sendPacketToClients(this.getDescriptionPacket(), worldObj, new Vector3(this).translate(new Vector3(.5f, 1f, .5f)), 64);
if (Math.abs(this.actualYaw - this.targetYaw) > 1) }
{ }
float speedYaw; this.updateRotation();
if (this.actualYaw > this.targetYaw) energy.extractEnergy();
{ }
if (Math.abs(this.actualYaw - this.targetYaw) >= 180) }
{
speedYaw = this.ROTATION_SPEED;
}
else
{
speedYaw = -this.ROTATION_SPEED;
}
}
else
{
if (Math.abs(this.actualYaw - this.targetYaw) >= 180)
{
speedYaw = -this.ROTATION_SPEED;
}
else
{
speedYaw = this.ROTATION_SPEED;
}
}
this.actualYaw += speedYaw; public void updateRotation()
{
// Clamp target angles
this.targetYaw = (int) MathUtility.clampAngleTo360(this.targetYaw);
if (this.targetPitch < 0)
this.targetPitch = 0;
if (this.targetPitch > 60)
this.targetPitch = 60;
// Handle change in yaw rotation
if (Math.abs(this.actualYaw - this.targetYaw) > 1)
{
float speedYaw;
if (this.actualYaw > this.targetYaw)
{
if (Math.abs(this.actualYaw - this.targetYaw) >= 180)
{
speedYaw = this.ROTATION_SPEED;
}
else
{
speedYaw = -this.ROTATION_SPEED;
}
}
else
{
if (Math.abs(this.actualYaw - this.targetYaw) >= 180)
{
speedYaw = -this.ROTATION_SPEED;
}
else
{
speedYaw = this.ROTATION_SPEED;
}
}
if (Math.abs(this.actualYaw - this.targetYaw) < this.ROTATION_SPEED) this.actualYaw += speedYaw;
{
this.actualYaw = this.targetYaw;
}
this.playRotationSound();
}
// Handle change in pitch rotation
if (Math.abs(this.actualPitch - this.targetPitch) > 1)
{
if (this.actualPitch > this.targetPitch)
{
this.actualPitch -= this.ROTATION_SPEED;
}
else
{
this.actualPitch += this.ROTATION_SPEED;
}
if (Math.abs(this.actualPitch - this.targetPitch) < this.ROTATION_SPEED) if (Math.abs(this.actualYaw - this.targetYaw) < this.ROTATION_SPEED)
{ {
this.actualPitch = this.targetPitch; this.actualYaw = this.targetYaw;
} }
this.playRotationSound(); this.playRotationSound();
} }
// Clamp actual angles angles // Handle change in pitch rotation
this.actualYaw = (int) MathUtility.clampAngleTo360(this.actualYaw); if (Math.abs(this.actualPitch - this.targetPitch) > 1)
if (this.actualPitch < 0) {
this.actualPitch = 0; if (this.actualPitch > this.targetPitch)
if (this.actualPitch > 60) {
this.actualPitch = 60; this.actualPitch -= this.ROTATION_SPEED;
} }
else
{
this.actualPitch += this.ROTATION_SPEED;
}
public void playRotationSound() if (Math.abs(this.actualPitch - this.targetPitch) < this.ROTATION_SPEED)
{ {
if (this.ticks % 5 == 0 && this.worldObj.isRemote) this.actualPitch = this.targetPitch;
{ }
this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "mods.assemblyline.conveyor", 2f, 2.5f, true); this.playRotationSound();
} }
} // Clamp actual angles angles
this.actualYaw = (int) MathUtility.clampAngleTo360(this.actualYaw);
if (this.actualPitch < 0)
this.actualPitch = 0;
if (this.actualPitch > 60)
this.actualPitch = 60;
}
public String getCommandDisplayText() public void playRotationSound()
{ {
return this.displayText; if (this.ticks % 5 == 0 && this.worldObj.isRemote)
} {
this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "mods.assemblyline.conveyor", 2f, 2.5f, true);
}
}
/************************************ Save and load code *************************************/ public String getCommandDisplayText()
{
return this.displayText;
}
/** NBT Data */ /************************************ Save and load code *************************************/
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
this.targetYaw = nbt.getInteger("armYaw"); /** NBT Data */
this.targetPitch = nbt.getInteger("armPitch"); @Override
this.actualYaw = nbt.getInteger("armYawActual"); public void readFromNBT(NBTTagCompound nbt)
this.actualPitch = nbt.getInteger("armPitchActual"); {
super.readFromNBT(nbt);
if (nbt.hasKey("grabbedEntity")) this.targetYaw = nbt.getInteger("armYaw");
{ this.targetPitch = nbt.getInteger("armPitch");
NBTTagCompound tag = nbt.getCompoundTag("grabbedEntity"); this.actualYaw = nbt.getInteger("armYawActual");
Entity entity = EntityList.createEntityFromNBT(tag, worldObj); this.actualPitch = nbt.getInteger("armPitchActual");
if (entity != null)
{
this.grabbedObject = entity;
this.spawnEntity = true;
}
}
else if (nbt.hasKey("grabbedItem"))
{
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("grabbedItem"));
if (stack != null)
{
this.grabbedObject = stack;
}
}
}
/** Writes a tile entity to NBT. */ if (nbt.hasKey("grabbedEntity"))
@Override {
public void writeToNBT(NBTTagCompound nbt) NBTTagCompound tag = nbt.getCompoundTag("grabbedEntity");
{ Entity entity = EntityList.createEntityFromNBT(tag, worldObj);
super.writeToNBT(nbt); if (entity != null)
{
this.grabbedObject = entity;
this.spawnEntity = true;
}
}
else if (nbt.hasKey("grabbedItem"))
{
ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("grabbedItem"));
if (stack != null)
{
this.grabbedObject = stack;
}
}
}
nbt.setInteger("armYaw", this.targetYaw); /** Writes a tile entity to NBT. */
nbt.setInteger("armPitch", this.targetPitch); @Override
nbt.setInteger("armYawActual", this.actualYaw); public void writeToNBT(NBTTagCompound nbt)
nbt.setInteger("armPitchActual", this.actualPitch); {
super.writeToNBT(nbt);
if (this.grabbedObject instanceof Entity) nbt.setInteger("armYaw", this.targetYaw);
{ nbt.setInteger("armPitch", this.targetPitch);
NBTTagCompound entityNBT = new NBTTagCompound(); nbt.setInteger("armYawActual", this.actualYaw);
((Entity) this.grabbedObject).writeToNBT(entityNBT); nbt.setInteger("armPitchActual", this.actualPitch);
((Entity) this.grabbedObject).writeToNBTOptional(entityNBT);
nbt.setCompoundTag("grabbedEntity", entityNBT);
}
else if (this.grabbedObject instanceof ItemStack)
{
nbt.setCompoundTag("grabbedItem", ((ItemStack) this.grabbedObject).writeToNBT(new NBTTagCompound()));
}
} if (this.grabbedObject instanceof Entity)
{
NBTTagCompound entityNBT = new NBTTagCompound();
((Entity) this.grabbedObject).writeToNBT(entityNBT);
((Entity) this.grabbedObject).writeToNBTOptional(entityNBT);
nbt.setCompoundTag("grabbedEntity", entityNBT);
}
else if (this.grabbedObject instanceof ItemStack)
{
nbt.setCompoundTag("grabbedItem", ((ItemStack) this.grabbedObject).writeToNBT(new NBTTagCompound()));
}
/************************************ Network Packet code *************************************/ }
@Override /************************************ Network Packet code *************************************/
public Packet getDescriptionPacket()
{
return ResonantInduction.PACKET_TILE.getPacket(this, "armbot", this.functioning, this.targetYaw, this.targetPitch, this.actualYaw, this.actualPitch);
}
public void sendGrabItemToClient() @Override
{ public Packet getDescriptionPacket()
if (this.grabbedObject instanceof ItemStack) {
{ return ResonantInduction.PACKET_TILE.getPacket(this, "armbot", energy.checkExtract(), this.targetYaw, this.targetPitch, this.actualYaw, this.actualPitch);
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, "armbotItem", true, ((ItemStack) this.grabbedObject).writeToNBT(new NBTTagCompound())), worldObj, new Vector3(this), 64); }
}
else
{
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, "armbotItem", false), worldObj, new Vector3(this), 64);
}
}
@Override public void sendGrabItemToClient()
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra) {
{ if (this.grabbedObject instanceof ItemStack)
try {
{ PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, "armbotItem", true, ((ItemStack) this.grabbedObject).writeToNBT(new NBTTagCompound())), worldObj, new Vector3(this), 64);
if (this.worldObj.isRemote && !super.onReceivePacket(id, data, player, extra)) }
{ else
if (id == ARMBOT_PACKET_ID) {
{ PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, "armbotItem", false), worldObj, new Vector3(this), 64);
this.functioning = data.readBoolean(); }
this.targetYaw = data.readInt(); }
this.targetPitch = data.readInt();
this.actualYaw = data.readInt();
this.actualPitch = data.readInt();
return true;
}
else if (id == ROTATION_PACKET_ID)
{
if (data.readBoolean())
{
this.grabbedObject = ItemStack.loadItemStackFromNBT(PacketHandler.readNBTTagCompound(data));
}
else
{
this.grabbedObject = null;
}
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
return false;
}
/************************************ Multi Block code *************************************/ @Override
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
try
{
if (this.worldObj.isRemote)
{
if (id == ARMBOT_PACKET_ID)
{
this.functioning = data.readBoolean();
this.targetYaw = data.readInt();
this.targetPitch = data.readInt();
this.actualYaw = data.readInt();
this.actualPitch = data.readInt();
return true;
}
else if (id == ROTATION_PACKET_ID)
{
if (data.readBoolean())
{
this.grabbedObject = ItemStack.loadItemStackFromNBT(PacketHandler.readNBTTagCompound(data));
}
else
{
this.grabbedObject = null;
}
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
return false;
}
@Override /************************************ Multi Block code *************************************/
public Vector3[] getMultiBlockVectors()
{
return new Vector3[] { new Vector3(this).translate(0, 1, 0) };
}
/************************************ Armbot API methods *************************************/ @Override
@Override public Vector3[] getMultiBlockVectors()
public Object getHeldObject() {
{ return new Vector3[] { new Vector3(0, 1, 0) };
return this.grabbedObject; }
}
@Override /************************************ Armbot API methods *************************************/
public boolean grabObject(Object entity) @Override
{ public Object getHeldObject()
if (this.getHeldObject() == null) {
{ return this.grabbedObject;
if (entity instanceof ItemStack) }
{
this.grabbedObject = entity;
this.sendGrabItemToClient();
return true;
}
else if (entity instanceof EntityItem)
{
this.grabbedObject = ((EntityItem) entity).getEntityItem();
((EntityItem) entity).setDead();
this.sendGrabItemToClient();
return true;
}
else if (entity instanceof Entity)
{
this.grabbedObject = entity;
return true;
}
}
return false;
}
@Override @Override
public boolean dropHeldObject() public boolean grabObject(Object entity)
{ {
if (this.getHeldObject() != null) if (this.getHeldObject() == null)
{ {
if (this.getHeldObject() instanceof ItemStack) if (entity instanceof ItemStack)
{ {
Vector3 handPosition = this.getHandPos(); this.grabbedObject = entity;
WorldUtility.dropItemStack(worldObj, handPosition, (ItemStack) this.getHeldObject(), false); this.sendGrabItemToClient();
} return true;
this.grabbedObject = null; }
this.sendGrabItemToClient(); else if (entity instanceof EntityItem)
return true; {
} this.grabbedObject = ((EntityItem) entity).getEntityItem();
return false; ((EntityItem) entity).setDead();
} this.sendGrabItemToClient();
return true;
}
else if (entity instanceof Entity)
{
this.grabbedObject = entity;
return true;
}
}
return false;
}
@Override @Override
public Vector3 getHandPos() public boolean dropHeldObject()
{ {
Vector3 position = new Vector3(this); if (this.getHeldObject() != null)
position.translate(0.5); {
position.translate(this.getDeltaHandPosition()); if (this.getHeldObject() instanceof ItemStack)
return position; {
} Vector3 handPosition = this.getHandPos();
WorldUtility.dropItemStack(worldObj, handPosition, (ItemStack) this.getHeldObject(), false);
}
this.grabbedObject = null;
this.sendGrabItemToClient();
return true;
}
return false;
}
public Vector3 getDeltaHandPosition() @Override
{ public Vector3 getHandPos()
// The distance of the position relative to the main position. {
double distance = 1f; Vector3 position = new Vector3(this);
Vector3 delta = new Vector3(); position.translate(0.5);
// The delta Y of the hand. position.translate(this.getDeltaHandPosition());
delta.y = Math.sin(Math.toRadians(this.actualPitch)) * distance * 2; return position;
// The horizontal delta of the hand. }
double dH = Math.cos(Math.toRadians(this.actualPitch)) * distance;
// The delta X and Z.
delta.x = Math.sin(Math.toRadians(-this.actualYaw)) * dH;
delta.z = Math.cos(Math.toRadians(-this.actualYaw)) * dH;
return delta;
}
@Override public Vector3 getDeltaHandPosition()
public Vector2 getRotation() {
{ // The distance of the position relative to the main position.
return new Vector2(this.actualYaw, this.actualPitch); double distance = 1f;
} Vector3 delta = new Vector3();
// The delta Y of the hand.
delta.y = Math.sin(Math.toRadians(this.actualPitch)) * distance * 2;
// The horizontal delta of the hand.
double dH = Math.cos(Math.toRadians(this.actualPitch)) * distance;
// The delta X and Z.
delta.x = Math.sin(Math.toRadians(-this.actualYaw)) * dH;
delta.z = Math.cos(Math.toRadians(-this.actualYaw)) * dH;
return delta;
}
@Override @Override
public void setRotation(int yaw, int pitch) public Vector2 getRotation()
{ {
if (!this.worldObj.isRemote) return new Vector2(this.actualYaw, this.actualPitch);
{ }
this.actualYaw = yaw;
this.actualPitch = pitch;
}
}
@Override @Override
public boolean moveArmTo(int yaw, int pitch) public void setRotation(int yaw, int pitch)
{ {
if (!this.worldObj.isRemote) if (!this.worldObj.isRemote)
{ {
this.targetYaw = yaw; this.actualYaw = yaw;
this.targetPitch = pitch; this.actualPitch = pitch;
return true; }
} }
return false;
}
@Override @Override
public boolean moveTo(ForgeDirection direction) public boolean moveArmTo(int yaw, int pitch)
{ {
if (direction == ForgeDirection.SOUTH) if (!this.worldObj.isRemote)
{ {
this.targetYaw = 0; this.targetYaw = yaw;
return true; this.targetPitch = pitch;
} return true;
else if (direction == ForgeDirection.EAST) }
{ return false;
this.targetYaw = 90; }
return true;
}
else if (direction == ForgeDirection.NORTH)
{
this.targetYaw = 180; @Override
return true; public boolean moveTo(ForgeDirection direction)
} {
else if (direction == ForgeDirection.WEST) if (direction == ForgeDirection.SOUTH)
{ {
this.targetYaw = 270; this.targetYaw = 0;
return true; return true;
} }
return false; else if (direction == ForgeDirection.EAST)
} {
this.targetYaw = 90;
return true;
}
else if (direction == ForgeDirection.NORTH)
{
@Override this.targetYaw = 180;
public IProgram getCurrentProgram() return true;
{ }
if (this.programHelper == null) else if (direction == ForgeDirection.WEST)
{ {
this.programHelper = new ProgramHelper(this); this.targetYaw = 270;
} return true;
if (this.programHelper != null) }
{ return false;
return this.programHelper.getProgram(); }
}
return null;
}
@Override @Override
public void setCurrentProgram(IProgram program) public IProgram getCurrentProgram()
{ {
if (this.programHelper == null) if (this.programHelper == null)
{ {
this.programHelper = new ProgramHelper(this); this.programHelper = new ProgramHelper(this);
} }
if (this.programHelper != null) if (this.programHelper != null)
{ {
this.programHelper.setProgram(program); return this.programHelper.getProgram();
} }
} return null;
}
@Override @Override
public boolean clear(Object object) public void setCurrentProgram(IProgram program)
{ {
if (this.grabbedObject != null && this.grabbedObject.equals(object)) if (this.programHelper == null)
{ {
this.grabbedObject = null; this.programHelper = new ProgramHelper(this);
return true; }
} if (this.programHelper != null)
return false; {
} this.programHelper.setProgram(program);
}
}
@Override @Override
public Pair<World, Vector3> getLocation() public boolean clear(Object object)
{ {
return this.location; if (this.grabbedObject != null && this.grabbedObject.equals(object))
} {
this.grabbedObject = null;
return true;
}
return false;
}
@Override
public Pair<World, Vector3> getLocation()
{
return this.location;
}
} }