Implemented "USE" command

This commit is contained in:
Brian Ricketts 2013-01-20 00:09:51 -06:00
parent d043109284
commit 76e81cf00a
3 changed files with 33 additions and 1 deletions

View file

@ -38,6 +38,7 @@ import assemblyline.common.machine.command.CommandGrab;
import assemblyline.common.machine.command.CommandManager;
import assemblyline.common.machine.command.CommandReturn;
import assemblyline.common.machine.command.CommandRotate;
import assemblyline.common.machine.command.CommandUse;
import assemblyline.common.machine.encoder.ItemDisk;
import com.google.common.io.ByteArrayDataInput;
@ -559,7 +560,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
@Override
public String[] getMethodNames()
{
return new String[] { "rotate", "grab", "drop", "reset", "isWorking", "touchingEntity" };
return new String[] { "rotate", "grab", "drop", "reset", "isWorking", "touchingEntity", "use" };
}
@Override
@ -625,6 +626,11 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
return new Object[] { false };
}
case 6:
{
this.commandManager.addCommand(this, CommandUse.class);
break;
}
}
return null;
}

View file

@ -32,6 +32,7 @@ public abstract class Command
registerCommand("rotate", CommandRotate.class);
registerCommand("return", CommandReturn.class);
registerCommand("repeat", CommandRepeat.class);
registerCommand("use", CommandUse.class);
}
public static void registerCommand(String command, Class<? extends Command> commandClass)

View file

@ -0,0 +1,25 @@
package assemblyline.common.machine.command;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import assemblyline.common.machine.armbot.IUseable;
public class CommandUse extends Command
{
@Override
protected boolean doTask()
{
TileEntity handTile = this.tileEntity.getHandPosition().getTileEntity(this.world);
Entity handEntity = null;
if (this.tileEntity.grabbedEntities.size() > 0)
handEntity = this.tileEntity.grabbedEntities.get(0);
if (handTile != null)
{
if (handTile instanceof IUseable)
{
((IUseable) handTile).onUse(this.tileEntity, handEntity);
}
}
return false;
}
}