61 lines
1.5 KiB
Java
61 lines
1.5 KiB
Java
package resonantinduction.electrical.armbot.command;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraftforge.common.ForgeDirection;
|
|
import resonantinduction.electrical.armbot.TaskBaseArmbot;
|
|
import resonantinduction.old.api.IArmbot;
|
|
import resonantinduction.old.api.IBelt;
|
|
import universalelectricity.api.vector.Vector2;
|
|
import universalelectricity.api.vector.Vector3;
|
|
|
|
/**
|
|
* Prefab for grab based commands
|
|
*
|
|
* @author DarkGuardsman
|
|
*/
|
|
public abstract class TaskGrabPrefab extends TaskBaseArmbot
|
|
{
|
|
public static final float radius = 0.5f;
|
|
protected Vector3 armPos;
|
|
protected IBelt belt;
|
|
|
|
public TaskGrabPrefab(String name)
|
|
{
|
|
super(name);
|
|
this.UV = new Vector2(0, 80);
|
|
}
|
|
|
|
@Override
|
|
public ProcessReturn onMethodCalled()
|
|
{
|
|
ProcessReturn re = super.onMethodCalled();
|
|
if (re == ProcessReturn.CONTINUE)
|
|
{
|
|
this.armPos = ((IArmbot) this.program.getMachine()).getHandPos();
|
|
TileEntity entity = this.armPos.getTileEntity(this.program.getMachine().getLocation().left());
|
|
if (entity == null)
|
|
{
|
|
entity = this.armPos.clone().translate(new Vector3(ForgeDirection.DOWN)).getTileEntity(this.program.getMachine().getLocation().left());
|
|
}
|
|
if (entity instanceof IBelt)
|
|
{
|
|
this.belt = (IBelt) entity;
|
|
}
|
|
return ProcessReturn.CONTINUE;
|
|
}
|
|
return re;
|
|
}
|
|
|
|
@Override
|
|
public ProcessReturn onUpdate()
|
|
{
|
|
super.onUpdate();
|
|
|
|
if (((IArmbot) this.program.getMachine()).getHeldObject() != null)
|
|
{
|
|
return ProcessReturn.DONE;
|
|
}
|
|
|
|
return ProcessReturn.CONTINUE;
|
|
}
|
|
}
|