Search in sources :

Example 1 with IMapLocation

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);
                }
            }
        }
    }
}
Also used : Packet(buildcraft.core.lib.network.base.Packet) ContainerZonePlan(buildcraft.robotics.gui.ContainerZonePlan) ZonePlan(buildcraft.robotics.zone.ZonePlan) IMapLocation(buildcraft.api.items.IMapLocation) PacketCommand(buildcraft.core.lib.network.command.PacketCommand) IZone(buildcraft.api.core.IZone) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ContainerZonePlan(buildcraft.robotics.gui.ContainerZonePlan) CommandWriter(buildcraft.core.lib.network.command.CommandWriter) ByteBuf(io.netty.buffer.ByteBuf)

Example 2 with IMapLocation

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;
}
Also used : DockingStation(buildcraft.api.robots.DockingStation) EnumFacing(net.minecraft.util.EnumFacing) IMapLocation(buildcraft.api.items.IMapLocation) BlockPos(net.minecraft.util.math.BlockPos) StatementParameterItemStack(buildcraft.api.statements.StatementParameterItemStack) ItemStack(net.minecraft.item.ItemStack)

Example 3 with IMapLocation

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;
}
Also used : IToolWrench(buildcraft.api.tools.IToolWrench) EnumFacing(net.minecraft.util.EnumFacing) IMapLocation(buildcraft.api.items.IMapLocation) ItemStack(net.minecraft.item.ItemStack) IPipePluggableItem(buildcraft.api.transport.pluggable.IPipePluggableItem) GatePluggable(buildcraft.transport.gates.GatePluggable)

Example 4 with IMapLocation

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);
}
Also used : IMapLocation(buildcraft.api.items.IMapLocation) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IMapLocation (buildcraft.api.items.IMapLocation)4 ItemStack (net.minecraft.item.ItemStack)3 EnumFacing (net.minecraft.util.EnumFacing)2 IZone (buildcraft.api.core.IZone)1 DockingStation (buildcraft.api.robots.DockingStation)1 StatementParameterItemStack (buildcraft.api.statements.StatementParameterItemStack)1 IToolWrench (buildcraft.api.tools.IToolWrench)1 IPipePluggableItem (buildcraft.api.transport.pluggable.IPipePluggableItem)1 Packet (buildcraft.core.lib.network.base.Packet)1 CommandWriter (buildcraft.core.lib.network.command.CommandWriter)1 PacketCommand (buildcraft.core.lib.network.command.PacketCommand)1 ContainerZonePlan (buildcraft.robotics.gui.ContainerZonePlan)1 ZonePlan (buildcraft.robotics.zone.ZonePlan)1 GatePluggable (buildcraft.transport.gates.GatePluggable)1 ByteBuf (io.netty.buffer.ByteBuf)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 BlockPos (net.minecraft.util.math.BlockPos)1