Fixed a few issues with the armbot
This commit is contained in:
parent
2fd1857482
commit
62f95b2f47
14 changed files with 48 additions and 56 deletions
|
@ -16,12 +16,12 @@ public interface IArmbot extends Cloneable, IProgrammableMachine
|
|||
public Vector2 getRotation();
|
||||
|
||||
/** Forces the rotation to the two angles */
|
||||
public void setRotation(float yaw, float pitch);
|
||||
public void setRotation(int yaw, int pitch);
|
||||
|
||||
/** Ask the armbot to rotate to face the given direction. Some bots may not support all angles
|
||||
*
|
||||
* @return true if the bot will comply. May return false if it can't */
|
||||
public boolean moveArmTo(float yaw, float pitch);
|
||||
public boolean moveArmTo(int yaw, int pitch);
|
||||
|
||||
/** Ask the armbot to rotate to face the given direction. Some bots may not support up and down
|
||||
*
|
||||
|
@ -29,22 +29,20 @@ public interface IArmbot extends Cloneable, IProgrammableMachine
|
|||
* @return true if the bot will comply. May return false if it can't */
|
||||
public boolean moveTo(ForgeDirection direction);
|
||||
|
||||
/** Object currently held. In some cases this can be a list or array but is suggest to only be
|
||||
* one object */
|
||||
public Object getHeldObject();
|
||||
|
||||
/** Adds an entity to the Armbot's grab list. Entity or ItemStack
|
||||
*
|
||||
* @entity - object to grab, can be anything though is suggest to be an entity or itemstack
|
||||
* @return - true if the bot has grabbed the object */
|
||||
public boolean grab(Object entity);
|
||||
public boolean grabObject(Object entity);
|
||||
|
||||
/** Drops an object. Does except strings with "All" resulting in dropping everything.
|
||||
*
|
||||
* @entity - can be anything though entity and itemstack are the main supported types
|
||||
* @return - true if the bot dropped the item */
|
||||
public boolean drop(Object object);
|
||||
/** Drops the current held object. Use getGrabbedObject to make sure this is the object to drop. */
|
||||
public boolean dropHeldObject();
|
||||
|
||||
/** Same as deleting the object */
|
||||
public boolean clear(Object object);
|
||||
|
||||
/** Object currently held. In some cases this can be a list or array but is suggest to only be
|
||||
* one object */
|
||||
public Object getGrabbedObject();
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class BlockArmbot extends BlockAssembly
|
|||
if (tileEntity instanceof TileEntityArmbot)
|
||||
{
|
||||
((TileEntityArmbot) tileEntity).onDestroy(tileEntity);
|
||||
((TileEntityArmbot) tileEntity).drop("all");
|
||||
((TileEntityArmbot) tileEntity).dropHeldObject();
|
||||
}
|
||||
|
||||
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
|
||||
|
|
|
@ -369,15 +369,15 @@ public class TileEntityArmbot extends TileEntityAssembly implements IMultiBlock,
|
|||
|
||||
/************************************ Armbot API methods *************************************/
|
||||
@Override
|
||||
public Object getGrabbedObject()
|
||||
public Object getHeldObject()
|
||||
{
|
||||
return this.grabbedObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean grab(Object entity)
|
||||
public boolean grabObject(Object entity)
|
||||
{
|
||||
if (this.getGrabbedObject() != null)
|
||||
if (this.getHeldObject() == null)
|
||||
{
|
||||
if (entity instanceof ItemStack)
|
||||
{
|
||||
|
@ -402,23 +402,18 @@ public class TileEntityArmbot extends TileEntityAssembly implements IMultiBlock,
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean drop(Object object)
|
||||
public boolean dropHeldObject()
|
||||
{
|
||||
if (object != null)
|
||||
if (this.getHeldObject() != null)
|
||||
{
|
||||
boolean drop = object instanceof String && ((String) object).equalsIgnoreCase("all");
|
||||
|
||||
if (object.equals(this.grabbedObject) || drop)
|
||||
if (this.getHeldObject() instanceof ItemStack)
|
||||
{
|
||||
if (object instanceof ItemStack && this.grabbedObject instanceof ItemStack)
|
||||
{
|
||||
Vector3 handPosition = this.getHandPos();
|
||||
DarksHelper.dropItemStack(worldObj, handPosition, (ItemStack) object, false);
|
||||
this.sendGrabItemToClient();
|
||||
}
|
||||
this.grabbedObject = null;
|
||||
return true;
|
||||
Vector3 handPosition = this.getHandPos();
|
||||
DarksHelper.dropItemStack(worldObj, handPosition, (ItemStack) this.getHeldObject(), false);
|
||||
this.sendGrabItemToClient();
|
||||
}
|
||||
this.grabbedObject = null;
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
|
@ -461,23 +456,22 @@ public class TileEntityArmbot extends TileEntityAssembly implements IMultiBlock,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(float yaw, float pitch)
|
||||
public void setRotation(int yaw, int pitch)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
this.actualYaw = (int) yaw;
|
||||
this.actualPitch = (int) pitch;
|
||||
this.actualYaw = yaw;
|
||||
this.actualPitch = pitch;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveArmTo(float yaw, float pitch)
|
||||
public boolean moveArmTo(int yaw, int pitch)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
this.targetYaw = (int) yaw;
|
||||
this.targetPitch = (int) pitch;
|
||||
this.targetYaw = yaw;
|
||||
this.targetPitch = pitch;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -55,7 +55,7 @@ public class TaskBreak extends TaskBaseArmbot
|
|||
}
|
||||
else
|
||||
{
|
||||
((IArmbot) this.program.getMachine()).grab(new EntityItem(location.left(), serachPosition.intX() + 0.5D, serachPosition.intY() + 0.5D, serachPosition.intZ() + 0.5D, items.get(0)));
|
||||
((IArmbot) this.program.getMachine()).grabObject(new EntityItem(location.left(), serachPosition.intX() + 0.5D, serachPosition.intY() + 0.5D, serachPosition.intZ() + 0.5D, items.get(0)));
|
||||
}
|
||||
|
||||
location.left().setBlock(serachPosition.intX(), serachPosition.intY(), serachPosition.intZ(), 0, 0, 3);
|
||||
|
|
|
@ -19,7 +19,7 @@ public class TaskDrop extends TaskBaseArmbot
|
|||
{
|
||||
if (super.onUpdate() == ProcessReturn.CONTINUE)
|
||||
{
|
||||
((IArmbot) this.program.getMachine()).drop("all");
|
||||
((IArmbot) this.program.getMachine()).dropHeldObject();
|
||||
}
|
||||
return ProcessReturn.DONE;
|
||||
}
|
||||
|
|
|
@ -85,10 +85,10 @@ public class TaskFire extends TaskBaseArmbot
|
|||
{
|
||||
this.finalVelocity = new Vector3(0, 0, 0);
|
||||
}
|
||||
if (((IArmbot) this.program.getMachine()).getGrabbedObject() != null)
|
||||
if (((IArmbot) this.program.getMachine()).getHeldObject() != null)
|
||||
{
|
||||
Entity held = null;
|
||||
Object obj = ((IArmbot) this.program.getMachine()).getGrabbedObject();
|
||||
Object obj = ((IArmbot) this.program.getMachine()).getHeldObject();
|
||||
Pair<World, Vector3> location = this.program.getMachine().getLocation();
|
||||
if (obj instanceof Entity)
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ public class TaskFire extends TaskBaseArmbot
|
|||
}
|
||||
else
|
||||
{
|
||||
((IArmbot) this.program.getMachine()).drop("all");
|
||||
((IArmbot) this.program.getMachine()).dropHeldObject();
|
||||
if (!location.left().isRemote)
|
||||
{
|
||||
location.left().removeEntity(held);
|
||||
|
@ -141,7 +141,7 @@ public class TaskFire extends TaskBaseArmbot
|
|||
}
|
||||
else
|
||||
{
|
||||
((IArmbot) this.program.getMachine()).drop("all");
|
||||
((IArmbot) this.program.getMachine()).dropHeldObject();
|
||||
held.motionX = this.finalVelocity.x;
|
||||
held.motionY = this.finalVelocity.y;
|
||||
held.motionZ = this.finalVelocity.z;
|
||||
|
|
|
@ -62,10 +62,10 @@ public class TaskGive extends TaskBaseArmbot
|
|||
{
|
||||
TileEntity targetTile = ((IArmbot) this.program.getMachine()).getHandPos().getTileEntity(this.program.getMachine().getLocation().left());
|
||||
|
||||
if (targetTile != null && ((IArmbot) this.program.getMachine()).getGrabbedObject() instanceof ItemStack)
|
||||
if (targetTile != null && ((IArmbot) this.program.getMachine()).getHeldObject() instanceof ItemStack)
|
||||
{
|
||||
ForgeDirection direction = MathHelper.getFacingDirectionFromAngle((float) ((IArmbot) this.program.getMachine()).getRotation().x);
|
||||
ItemStack itemStack = (ItemStack) ((IArmbot) this.program.getMachine()).getGrabbedObject();
|
||||
ItemStack itemStack = (ItemStack) ((IArmbot) this.program.getMachine()).getHeldObject();
|
||||
List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
if (this.stack != null)
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ public class TaskGive extends TaskBaseArmbot
|
|||
ItemStack insertStack = invEx.tryPlaceInPosition(itemStack, new Vector3(targetTile), direction.getOpposite());
|
||||
if (((IArmbot) this.program.getMachine()).clear(itemStack))
|
||||
{
|
||||
((IArmbot) this.program.getMachine()).grab(insertStack);
|
||||
((IArmbot) this.program.getMachine()).grabObject(insertStack);
|
||||
}
|
||||
}
|
||||
return ProcessReturn.CONTINUE;
|
||||
|
|
|
@ -62,7 +62,7 @@ public class TaskGrabEntity extends TaskGrabPrefab
|
|||
{
|
||||
if (super.onUpdate() == ProcessReturn.CONTINUE)
|
||||
{
|
||||
if (((IArmbot) this.program.getMachine()).getGrabbedObject() != null)
|
||||
if (((IArmbot) this.program.getMachine()).getHeldObject() != null)
|
||||
{
|
||||
return ProcessReturn.DONE;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class TaskGrabEntity extends TaskGrabPrefab
|
|||
{
|
||||
if ((entity != null && !(entity instanceof EntityArrow) && !(entity instanceof EntityPlayer) && (!(entity instanceof EntityAgeable) || (entity instanceof EntityAgeable && child == ((EntityAgeable) entity).isChild()))))
|
||||
{
|
||||
((IArmbot) this.program.getMachine()).grab(entity);
|
||||
((IArmbot) this.program.getMachine()).grabObject(entity);
|
||||
if (this.belt != null)
|
||||
{
|
||||
belt.ignoreEntity(entity);
|
||||
|
|
|
@ -48,7 +48,7 @@ public class TaskGrabItem extends TaskGrabPrefab
|
|||
{
|
||||
if (super.onUpdate() == ProcessReturn.CONTINUE)
|
||||
{
|
||||
if (((IArmbot) this.program.getMachine()).getGrabbedObject() != null)
|
||||
if (((IArmbot) this.program.getMachine()).getHeldObject() != null)
|
||||
{
|
||||
return ProcessReturn.DONE;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class TaskGrabItem extends TaskGrabPrefab
|
|||
{
|
||||
if (stack == null || item.getEntityItem().isItemEqual(stack))
|
||||
{
|
||||
if (((IArmbot) this.program.getMachine()).grab(item))
|
||||
if (((IArmbot) this.program.getMachine()).grabObject(item))
|
||||
{
|
||||
if (this.belt != null)
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ public abstract class TaskGrabPrefab extends TaskBaseArmbot
|
|||
{
|
||||
super.onUpdate();
|
||||
|
||||
if (((IArmbot) this.program.getMachine()).getGrabbedObject() != null)
|
||||
if (((IArmbot) this.program.getMachine()).getHeldObject() != null)
|
||||
{
|
||||
return ProcessReturn.DONE;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class TaskPlace extends TaskBaseArmbot
|
|||
|
||||
if (block == null && ticks >= this.PLACE_TIME)
|
||||
{
|
||||
Object entity = ((IArmbot) this.program.getMachine()).getGrabbedObject();
|
||||
Object entity = ((IArmbot) this.program.getMachine()).getHeldObject();
|
||||
ItemStack itemStack = null;
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ public class TaskTake extends TaskBaseArmbot
|
|||
{
|
||||
TileEntity targetTile = ((IArmbot) this.program.getMachine()).getHandPos().getTileEntity(this.program.getMachine().getLocation().left());
|
||||
|
||||
if (targetTile != null && ((IArmbot) this.program.getMachine()).getGrabbedObject() instanceof ItemStack)
|
||||
if (targetTile != null && ((IArmbot) this.program.getMachine()).getHeldObject() instanceof ItemStack)
|
||||
{
|
||||
ForgeDirection direction = MathHelper.getFacingDirectionFromAngle(((IArmbot) this.program.getMachine()).getRotation().x);
|
||||
List<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
|
@ -69,8 +69,8 @@ public class TaskTake extends TaskBaseArmbot
|
|||
stacks.add(stack);
|
||||
}
|
||||
InvInteractionHelper invEx = new InvInteractionHelper(this.program.getMachine().getLocation().left(), this.program.getMachine().getLocation().right(), stacks, false);
|
||||
((IArmbot) this.program.getMachine()).grab(invEx.tryGrabFromPosition(new Vector3(targetTile), direction, this.stack != null ? stack.stackSize : 1));
|
||||
return ((IArmbot) this.program.getMachine()).getGrabbedObject() != null ? ProcessReturn.DONE : ProcessReturn.CONTINUE;
|
||||
((IArmbot) this.program.getMachine()).grabObject(invEx.tryGrabFromPosition(new Vector3(targetTile), direction, this.stack != null ? stack.stackSize : 1));
|
||||
return ((IArmbot) this.program.getMachine()).getHeldObject() != null ? ProcessReturn.DONE : ProcessReturn.CONTINUE;
|
||||
|
||||
}
|
||||
return ProcessReturn.CONTINUE;
|
||||
|
|
|
@ -67,9 +67,9 @@ public class RenderArmbot extends TileEntitySpecialRenderer
|
|||
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
|
||||
|
||||
// Items don't move right, so we render them manually. Client side this can only be one object so the bot should return its preferred render item client side
|
||||
if (((TileEntityArmbot) tileEntity).getGrabbedObject() instanceof ItemStack)
|
||||
if (((TileEntityArmbot) tileEntity).getHeldObject() instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack) ((TileEntityArmbot) tileEntity).getGrabbedObject();
|
||||
ItemStack itemStack = (ItemStack) ((TileEntityArmbot) tileEntity).getHeldObject();
|
||||
if (((TileEntityArmbot) tileEntity).renderEntityItem == null)
|
||||
{
|
||||
((TileEntityArmbot) tileEntity).renderEntityItem = new EntityItem(tileEntity.worldObj, 0, 0, 0, itemStack);
|
||||
|
|
|
@ -391,7 +391,7 @@ public class TileEntityImprinter extends TileEntityAdvanced implements ISidedInv
|
|||
AutoCraftEvent.PreCraft event = new AutoCraftEvent.PreCraft(this.worldObj, new Vector3(this), this, this.imprinterMatrix[craftingOutputSlot]);
|
||||
if (!event.isCanceled())
|
||||
{
|
||||
armbot.grab(this.imprinterMatrix[craftingOutputSlot].copy());
|
||||
armbot.grabObject(this.imprinterMatrix[craftingOutputSlot].copy());
|
||||
this.onPickUpFromSlot(null, 2, this.imprinterMatrix[craftingOutputSlot]);
|
||||
this.imprinterMatrix[craftingOutputSlot] = null;
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue