Search in sources :

Example 1 with ContainerZonePlan

use of buildcraft.robotics.gui.ContainerZonePlan 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 ContainerZonePlan

use of buildcraft.robotics.gui.ContainerZonePlan in project BuildCraft by BuildCraft.

the class RoboticsGuiHandler method getServerGuiElement.

@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
    BlockPos pos = new BlockPos(x, y, z);
    if (!world.isBlockLoaded(pos)) {
        return null;
    }
    TileEntity tile = world.getTileEntity(pos);
    switch(id) {
        case GuiIds.MAP:
            if (!(tile instanceof TileZonePlan)) {
                return null;
            } else {
                return new ContainerZonePlan(player, (TileZonePlan) tile);
            }
        case GuiIds.REQUESTER:
            if (!(tile instanceof TileRequester)) {
                return null;
            } else {
                return new ContainerRequester(player, (TileRequester) tile);
            }
        default:
            return null;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ContainerRequester(buildcraft.robotics.gui.ContainerRequester) BlockPos(net.minecraft.util.math.BlockPos) ContainerZonePlan(buildcraft.robotics.gui.ContainerZonePlan)

Aggregations

ContainerZonePlan (buildcraft.robotics.gui.ContainerZonePlan)2 IZone (buildcraft.api.core.IZone)1 IMapLocation (buildcraft.api.items.IMapLocation)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 ContainerRequester (buildcraft.robotics.gui.ContainerRequester)1 ZonePlan (buildcraft.robotics.zone.ZonePlan)1 ByteBuf (io.netty.buffer.ByteBuf)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1