Search in sources :

Example 1 with ZonePlan

use of buildcraft.robotics.zone.ZonePlan in project BuildCraft by BuildCraft.

the class GuiZonePlanner method mouseClickMove.

@Override
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
    super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
    if (!canDrag) {
        if (lastSelected != null && getPaintbrushBrush() != null) {
            bufferLayer = new ZonePlan(container.tile.layers[getPaintbrushBrush().colour.getMetadata()]);
            if (selectionStartXZ != null && getPaintbrushBrush() != null && lastSelected != null) {
                for (int x = Math.min(selectionStartXZ.getX(), lastSelected.getX()); x < Math.max(selectionStartXZ.getX(), lastSelected.getX()); x++) {
                    for (int z = Math.min(selectionStartXZ.getZ(), lastSelected.getZ()); z < Math.max(selectionStartXZ.getZ(), lastSelected.getZ()); z++) {
                        if (clickedMouseButton == 0) {
                            bufferLayer.set(x - container.tile.getPos().getX(), z - container.tile.getPos().getZ(), true);
                        } else if (clickedMouseButton == 1) {
                            bufferLayer.set(x - container.tile.getPos().getX(), z - container.tile.getPos().getZ(), false);
                        }
                    }
                }
            }
        }
        return;
    }
    float deltaX = mouseX - startMouseX;
    float deltaY = mouseY - startMouseY;
    float s = 0.3F;
    positionX = startPositionX - deltaX * s;
    positionZ = startPositionZ - deltaY * s;
}
Also used : ZonePlan(buildcraft.robotics.zone.ZonePlan)

Example 2 with ZonePlan

use of buildcraft.robotics.zone.ZonePlan in project BuildCraft by BuildCraft.

the class TileZonePlan method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    mapName = nbt.getString("name");
    if (mapName == null) {
        mapName = "";
    }
    inv.readFromNBT(nbt.getCompoundTag("inv"));
    for (int i = 0; i < selectedAreas.length; ++i) {
        if (nbt.hasKey("selectedArea[" + i + "]")) {
            selectedAreas[i] = new ZonePlan();
            selectedAreas[i].readFromNBT(nbt.getCompoundTag("selectedArea[" + i + "]"));
        }
    }
}
Also used : ContainerZonePlan(buildcraft.robotics.gui.ContainerZonePlan) ZonePlan(buildcraft.robotics.zone.ZonePlan)

Example 3 with ZonePlan

use of buildcraft.robotics.zone.ZonePlan 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 4 with ZonePlan

use of buildcraft.robotics.zone.ZonePlan in project BuildCraft by BuildCraft.

the class ContainerZonePlan method receiveCommand.

@Override
public void receiveCommand(String command, Side side, Object sender, ByteBuf stream) {
    if (side.isClient()) {
        if ("areaLoaded".equals(command)) {
            currentAreaSelection = new ZonePlan();
            currentAreaSelection.readData(stream);
            gui.refreshSelectedArea();
        } else if ("receiveImage".equals(command)) {
            int size = stream.readUnsignedMedium();
            int pos = stream.readUnsignedMedium();
            for (int i = 0; i < Math.min(size - pos, MAX_PACKET_LENGTH); ++i) {
                mapTexture.colorMap[pos + i] = 0xFF000000 | MapColor.mapColorArray[stream.readUnsignedByte()].colorValue;
            }
        }
    } else if (side.isServer()) {
        if ("loadArea".equals(command)) {
            final int index = stream.readUnsignedByte();
            BuildCraftCore.instance.sendToPlayer((EntityPlayer) sender, new PacketCommand(this, "areaLoaded", new CommandWriter() {

                @Override
                public void write(ByteBuf data) {
                    map.selectArea(index).writeData(data);
                }
            }));
        } else if ("saveArea".equals(command)) {
            final int index = stream.readUnsignedByte();
            ZonePlan plan = new ZonePlan();
            plan.readData(stream);
            map.setArea(index, plan);
        } else if ("computeMap".equals(command)) {
            computeMap(stream.readInt(), stream.readInt(), stream.readUnsignedShort(), stream.readUnsignedShort(), stream.readFloat(), (EntityPlayer) sender);
        } else if ("setName".equals(command)) {
            map.mapName = NetworkUtils.readUTF(stream);
        }
    }
}
Also used : TileZonePlan(buildcraft.robotics.TileZonePlan) ZonePlan(buildcraft.robotics.zone.ZonePlan) PacketCommand(buildcraft.core.lib.network.command.PacketCommand) EntityPlayer(net.minecraft.entity.player.EntityPlayer) CommandWriter(buildcraft.core.lib.network.command.CommandWriter) ByteBuf(io.netty.buffer.ByteBuf)

Example 5 with ZonePlan

use of buildcraft.robotics.zone.ZonePlan in project BuildCraft by BuildCraft.

the class ItemMapLocation method getZone.

@Override
public IZone getZone(@Nonnull ItemStack item) {
    NBTTagCompound cpt = NBTUtilBC.getItemData(item);
    MapLocationType type = MapLocationType.getFromStack(item);
    switch(type) {
        case ZONE:
            {
                ZonePlan plan = new ZonePlan();
                plan.readFromNBT(cpt);
                return plan;
            }
        case AREA:
            {
                return getBox(item);
            }
        case PATH:
        case PATH_REPEATING:
            {
                return getPointBox(item);
            }
        default:
            {
                return null;
            }
    }
}
Also used : ZonePlan(buildcraft.robotics.zone.ZonePlan) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

ZonePlan (buildcraft.robotics.zone.ZonePlan)10 ItemPaintbrush_BC8 (buildcraft.core.item.ItemPaintbrush_BC8)2 CommandWriter (buildcraft.core.lib.network.command.CommandWriter)2 PacketCommand (buildcraft.core.lib.network.command.PacketCommand)2 ContainerZonePlan (buildcraft.robotics.gui.ContainerZonePlan)2 ByteBuf (io.netty.buffer.ByteBuf)2 ItemStack (net.minecraft.item.ItemStack)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 IZone (buildcraft.api.core.IZone)1 IMapLocation (buildcraft.api.items.IMapLocation)1 BCCoreItems (buildcraft.core.BCCoreItems)1 ItemMapLocation (buildcraft.core.item.ItemMapLocation)1 Packet (buildcraft.core.lib.network.base.Packet)1 GuiBC8 (buildcraft.lib.gui.GuiBC8)1 GuiIcon (buildcraft.lib.gui.GuiIcon)1 GuiRectangle (buildcraft.lib.gui.pos.GuiRectangle)1 TileZonePlan (buildcraft.robotics.TileZonePlan)1 ContainerZonePlanner (buildcraft.robotics.container.ContainerZonePlanner)1 ZonePlannerMapChunk (buildcraft.robotics.zone.ZonePlannerMapChunk)1 MapColourData (buildcraft.robotics.zone.ZonePlannerMapChunk.MapColourData)1