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;
}
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 + "]"));
}
}
}
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);
}
}
}
}
}
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);
}
}
}
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;
}
}
}
Aggregations