use of buildcraft.api.items.IMapLocation in project BuildCraft by BuildCraft.
the class TileZonePlan method importMap.
private void importMap(ItemStack stack) {
if (stack != null && stack.getItem() instanceof IMapLocation) {
final IZone zone = ((IMapLocation) stack.getItem()).getZone(stack);
if (zone != null && zone instanceof ZonePlan) {
selectedAreas[currentSelectedArea] = (ZonePlan) zone;
for (EntityPlayerMP e : MinecraftServer.getServer().getConfigurationManager().playerEntityList) {
if (e.openContainer != null && e.openContainer instanceof ContainerZonePlan && ((ContainerZonePlan) e.openContainer).getTile() == this) {
Packet p = new PacketCommand(e.openContainer, "areaLoaded", new CommandWriter() {
@Override
public void write(ByteBuf data) {
((ZonePlan) zone).writeData(data);
}
});
BuildCraftCore.instance.sendToPlayer(e, p);
}
}
}
}
}
use of buildcraft.api.items.IMapLocation in project BuildCraft by BuildCraft.
the class ActionRobotGotoStation method getStation.
private DockingStation getStation(StatementParameterItemStack stackParam, IRobotRegistry registry) {
ItemStack item = stackParam.getItemStack();
if (item != null && item.getItem() instanceof IMapLocation) {
IMapLocation map = (IMapLocation) item.getItem();
BlockPos index = map.getPoint(item);
if (index != null) {
EnumFacing side = map.getPointSide(item);
DockingStation paramStation = registry.getStation(index, side);
if (paramStation != null) {
return paramStation;
}
}
}
return null;
}
use of buildcraft.api.items.IMapLocation in project BuildCraft by BuildCraft.
the class BlockGenericPipe method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float xOffset, float yOffset, float zOffset) {
if (super.onBlockActivated(world, pos, state, player, side, xOffset, yOffset, zOffset)) {
return true;
}
world.notifyBlockOfStateChange(pos, BuildCraftTransport.genericPipeBlock);
Pipe<?> pipe = getPipe(world, pos);
RaytraceResult rayTrace = doRayTrace(world, pos, player);
if (rayTrace != null) {
side = rayTrace.sideHit;
}
if (isValid(pipe)) {
ItemStack currentItem = player.getCurrentEquippedItem();
// from the pipe.
if (player.isSneaking() && currentItem == null) {
if (stripEquipment(world, pos, player, pipe, side)) {
return true;
}
} else if (currentItem == null) {
// Fall through the end of the test
} else if (currentItem.getItem() == Items.sign) {
// Sign will be placed anyway, so lets show the sign gui
return false;
} else if (currentItem.getItem() instanceof ItemPipe) {
return false;
} else if (currentItem.getItem() instanceof ItemGateCopier) {
return false;
} else if (currentItem.getItem() instanceof IToolWrench) {
// Only check the instance at this point. Call the IToolWrench
// interface callbacks for the individual pipe/logic calls
RaytraceResult rayTraceResult = doRayTrace(world, pos, player);
if (rayTraceResult != null) {
EnumFacing hitSide = rayTraceResult.hitPart == Part.Pipe ? rayTraceResult.sideHit : null;
return pipe.blockActivated(player, hitSide);
} else {
return pipe.blockActivated(player, null);
}
} else if (currentItem.getItem() instanceof IMapLocation) {
// We want to be able to record pipe locations
return false;
} else if (PipeWire.RED.isPipeWire(currentItem)) {
if (addOrStripWire(player, pipe, PipeWire.RED)) {
return true;
}
} else if (PipeWire.BLUE.isPipeWire(currentItem)) {
if (addOrStripWire(player, pipe, PipeWire.BLUE)) {
return true;
}
} else if (PipeWire.GREEN.isPipeWire(currentItem)) {
if (addOrStripWire(player, pipe, PipeWire.GREEN)) {
return true;
}
} else if (PipeWire.YELLOW.isPipeWire(currentItem)) {
if (addOrStripWire(player, pipe, PipeWire.YELLOW)) {
return true;
}
} else if (currentItem.getItem() == Items.water_bucket) {
if (!world.isRemote) {
pipe.container.setPipeColor(-1);
}
return true;
} else if (currentItem.getItem() instanceof IPipePluggableItem) {
if (addOrStripPipePluggable(world, pos, currentItem, player, side, pipe)) {
return true;
}
}
Gate clickedGate = null;
if (rayTrace != null && rayTrace.hitPart == Part.Pluggable && pipe.container.getPipePluggable(rayTrace.sideHit) instanceof GatePluggable) {
clickedGate = pipe.gates[rayTrace.sideHit.ordinal()];
}
if (clickedGate != null) {
clickedGate.openGui(player);
return true;
} else {
if (pipe.blockActivated(player, side)) {
return true;
}
if (rayTrace != null) {
EnumFacing hitSide = rayTrace.hitPart == Part.Pipe ? rayTrace.sideHit : null;
return pipe.blockActivated(player, hitSide);
}
}
}
return false;
}
use of buildcraft.api.items.IMapLocation in project BuildCraft by BuildCraft.
the class ActionRobotWorkInArea method getArea.
public static IZone getArea(StatementSlot slot) {
if (slot.parameters[0] == null) {
return null;
}
ItemStack stack = slot.parameters[0].getItemStack();
if (stack == null || !(stack.getItem() instanceof IMapLocation)) {
return null;
}
IMapLocation map = (IMapLocation) stack.getItem();
return map.getZone(stack);
}
Aggregations