use of buildcraft.robotics.EntityRobot in project BuildCraft by BuildCraft.
the class ActionRobotGotoStation method actionActivate.
@Override
public void actionActivate(IStatementContainer container, IStatementParameter[] parameters) {
IRobotRegistry registry = RobotManager.registryProvider.getRegistry(container.getTile().getWorld());
List<DockingStation> stations = RobotUtils.getStations(container.getTile());
for (DockingStation station : stations) {
if (station.robotTaking() != null) {
EntityRobot robot = (EntityRobot) station.robotTaking();
AIRobot ai = robot.getOverridingAI();
if (ai != null) {
continue;
}
DockingStation newStation = station;
if (parameters[0] != null) {
newStation = getStation((StatementParameterItemStack) parameters[0], registry);
}
if (newStation != null) {
robot.overrideAI(new AIRobotGoAndLinkToDock(robot, newStation));
}
}
}
}
use of buildcraft.robotics.EntityRobot in project LogisticsPipes by RS485.
the class BuildCraftProxy method checkRobot.
/**
* @see buildcraft.robotics.ItemRobot#onItemUse(ItemStack, EntityPlayer,
* World, int, int, int, int, float, float, float)
*/
private boolean checkRobot(World world, int x, int y, int z, EntityPlayer player, ItemStack currentItem) {
if (!world.isRemote) {
Pipe<?> bcPipe = BlockGenericPipe.getPipe(world, x, y, z);
if (bcPipe == null) {
return false;
}
BlockGenericPipe pipeBlock = BuildCraftTransport.genericPipeBlock;
BlockGenericPipe.RaytraceResult rayTraceResult = pipeBlock.doRayTrace(world, x, y, z, player);
if (rayTraceResult != null && rayTraceResult.hitPart == BlockGenericPipe.Part.Pluggable && bcPipe.container.getPipePluggable(rayTraceResult.sideHit) instanceof RobotStationPluggable) {
RobotStationPluggable pluggable = (RobotStationPluggable) bcPipe.container.getPipePluggable(rayTraceResult.sideHit);
DockingStation station = pluggable.getStation();
if (!station.isTaken()) {
RedstoneBoardRobotNBT robotNBT = ItemRobot.getRobotNBT(currentItem);
if (robotNBT == RedstoneBoardRegistry.instance.getEmptyRobotBoard()) {
return true;
}
EntityRobot robot = ((ItemRobot) currentItem.getItem()).createRobot(currentItem, world);
RobotEvent.Place robotEvent = new RobotEvent.Place(robot, player);
FMLCommonHandler.instance().bus().post(robotEvent);
if (robotEvent.isCanceled()) {
return true;
}
if (robot != null && robot.getRegistry() != null) {
robot.setUniqueRobotId(robot.getRegistry().getNextRobotId());
float px = x + 0.5F + rayTraceResult.sideHit.offsetX * 0.5F;
float py = y + 0.5F + rayTraceResult.sideHit.offsetY * 0.5F;
float pz = z + 0.5F + rayTraceResult.sideHit.offsetZ * 0.5F;
robot.setPosition(px, py, pz);
station.takeAsMain(robot);
robot.dock(robot.getLinkedStation());
world.spawnEntityInWorld(robot);
if (!player.capabilities.isCreativeMode) {
player.getCurrentEquippedItem().stackSize--;
}
}
}
return true;
}
}
return false;
}
Aggregations