Implemented "USE" command
This commit is contained in:
parent
d043109284
commit
76e81cf00a
3 changed files with 33 additions and 1 deletions
|
@ -38,6 +38,7 @@ import assemblyline.common.machine.command.CommandGrab;
|
||||||
import assemblyline.common.machine.command.CommandManager;
|
import assemblyline.common.machine.command.CommandManager;
|
||||||
import assemblyline.common.machine.command.CommandReturn;
|
import assemblyline.common.machine.command.CommandReturn;
|
||||||
import assemblyline.common.machine.command.CommandRotate;
|
import assemblyline.common.machine.command.CommandRotate;
|
||||||
|
import assemblyline.common.machine.command.CommandUse;
|
||||||
import assemblyline.common.machine.encoder.ItemDisk;
|
import assemblyline.common.machine.encoder.ItemDisk;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
@ -559,7 +560,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
|
||||||
@Override
|
@Override
|
||||||
public String[] getMethodNames()
|
public String[] getMethodNames()
|
||||||
{
|
{
|
||||||
return new String[] { "rotate", "grab", "drop", "reset", "isWorking", "touchingEntity" };
|
return new String[] { "rotate", "grab", "drop", "reset", "isWorking", "touchingEntity", "use" };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -625,6 +626,11 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
|
||||||
|
|
||||||
return new Object[] { false };
|
return new Object[] { false };
|
||||||
}
|
}
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
this.commandManager.addCommand(this, CommandUse.class);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ public abstract class Command
|
||||||
registerCommand("rotate", CommandRotate.class);
|
registerCommand("rotate", CommandRotate.class);
|
||||||
registerCommand("return", CommandReturn.class);
|
registerCommand("return", CommandReturn.class);
|
||||||
registerCommand("repeat", CommandRepeat.class);
|
registerCommand("repeat", CommandRepeat.class);
|
||||||
|
registerCommand("use", CommandUse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerCommand(String command, Class<? extends Command> commandClass)
|
public static void registerCommand(String command, Class<? extends Command> commandClass)
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue