Search in sources :

Example 51 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class LiquidMonitorBlockTileEntity method findAdjacentBlocks.

public List<Coordinate> findAdjacentBlocks() {
    int x = xCoord;
    int y = yCoord;
    int z = zCoord;
    List<Coordinate> adjacentBlocks = new ArrayList<Coordinate>();
    for (int dy = -1; dy <= 1; dy++) {
        int yy = y + dy;
        if (yy >= 0 && yy < worldObj.getHeight()) {
            for (int dz = -1; dz <= 1; dz++) {
                int zz = z + dz;
                for (int dx = -1; dx <= 1; dx++) {
                    int xx = x + dx;
                    if (dx != 0 || dy != 0 || dz != 0) {
                        TileEntity tileEntity = worldObj.getTileEntity(xx, yy, zz);
                        if (tileEntity instanceof IFluidHandler) {
                            adjacentBlocks.add(new Coordinate(xx, yy, zz));
                        }
                    }
                }
            }
        }
    }
    return adjacentBlocks;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) GenericTileEntity(mcjty.lib.entity.GenericTileEntity) Coordinate(mcjty.lib.varia.Coordinate) ArrayList(java.util.ArrayList) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 52 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class PacketContentsMonitor method fromBytes.

@Override
public void fromBytes(ByteBuf buf) {
    x = buf.readInt();
    y = buf.readInt();
    z = buf.readInt();
    monitor = new Coordinate(buf.readInt(), buf.readInt(), buf.readInt());
    alarmLevel = buf.readByte();
    alarmMode = RFMonitorMode.getModeFromIndex(buf.readByte());
}
Also used : Coordinate(mcjty.lib.varia.Coordinate)

Example 53 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class GuiLiquidMonitor method populateList.

private void populateList() {
    List<Coordinate> newAdjacentBlocks = fromServer_clientAdjacentBlocks;
    if (newAdjacentBlocks == null) {
        return;
    }
    if (newAdjacentBlocks.equals(adjacentBlocks)) {
        refreshList();
        return;
    }
    adjacentBlocks = new ArrayList<Coordinate>(newAdjacentBlocks);
    list.removeChildren();
    int index = 0, sel = -1;
    for (Coordinate coordinate : adjacentBlocks) {
        Block block = mc.theWorld.getBlock(coordinate.getX(), coordinate.getY(), coordinate.getZ());
        int meta = mc.theWorld.getBlockMetadata(coordinate.getX(), coordinate.getY(), coordinate.getZ());
        int color = StyleConfig.colorTextInListNormal;
        String displayName = BlockInfo.getReadableName(block, coordinate, meta, mc.theWorld);
        if (coordinate.getX() == tileEntity.getMonitorX() && coordinate.getY() == tileEntity.getMonitorY() && coordinate.getZ() == tileEntity.getMonitorZ()) {
            sel = index;
            color = TEXT_COLOR_SELECTED;
        }
        Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout());
        panel.addChild(new BlockRender(mc, this).setRenderItem(block));
        panel.addChild(new Label(mc, this).setText(displayName).setColor(color).setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT).setDesiredWidth(90));
        panel.addChild(new Label(mc, this).setDynamic(true).setText(coordinate.toString()).setColor(color));
        list.addChild(panel);
        index++;
    }
    list.setSelected(sel);
}
Also used : Panel(mcjty.lib.gui.widgets.Panel) Coordinate(mcjty.lib.varia.Coordinate) Label(mcjty.lib.gui.widgets.Label) Block(net.minecraft.block.Block) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout)

Example 54 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class CounterPlusScreenModule method setupFromNBT.

@Override
public void setupFromNBT(NBTTagCompound tagCompound, int dim, int x, int y, int z) {
    if (tagCompound != null) {
        coordinate = Coordinate.INVALID;
        if (tagCompound.hasKey("monitorx")) {
            this.dim = tagCompound.getInteger("dim");
            coordinate = new Coordinate(tagCompound.getInteger("monitorx"), tagCompound.getInteger("monitory"), tagCompound.getInteger("monitorz"));
        }
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate)

Example 55 with Coordinate

use of mcjty.lib.varia.Coordinate in project RFTools by McJty.

the class StorageScannerTileEntity method startScan.

public void startScan(boolean start) {
    if (!worldObj.isRemote) {
        if (!start) {
            scanning.setValue(false);
            notifyBlockUpdate();
            return;
        }
        int r = radius.getValue();
        // Only on server
        int y1 = yCoord - r;
        if (y1 < 0) {
            y1 = 0;
        }
        c1.setCoordinate(new Coordinate(xCoord - r, y1, zCoord - r));
        int y2 = yCoord + r;
        if (y2 >= worldObj.getHeight()) {
            y2 = worldObj.getHeight() - 1;
        }
        c2.setCoordinate(new Coordinate(xCoord + r, y2, zCoord + r));
        scanning.setValue(true);
        cur.setCoordinate(c1.getCoordinate());
        inventories.clear();
        notifyBlockUpdate();
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate) SyncedCoordinate(mcjty.lib.entity.SyncedCoordinate)

Aggregations

Coordinate (mcjty.lib.varia.Coordinate)181 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)63 TileEntity (net.minecraft.tileentity.TileEntity)30 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)19 Block (net.minecraft.block.Block)14 HashMap (java.util.HashMap)13 Map (java.util.Map)13 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)13 World (net.minecraft.world.World)12 NBTTagList (net.minecraft.nbt.NBTTagList)11 Callback (li.cil.oc.api.machine.Callback)10 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)10 Panel (mcjty.lib.gui.widgets.Panel)10 ItemStack (net.minecraft.item.ItemStack)10 ArrayList (java.util.ArrayList)9 Label (mcjty.lib.gui.widgets.Label)8 BlockInfo (mcjty.rftools.BlockInfo)7 SyncedCoordinate (mcjty.lib.entity.SyncedCoordinate)5 ChoiceEvent (mcjty.lib.gui.events.ChoiceEvent)4 TeleportDestinationClientInfo (mcjty.rftools.blocks.teleporter.TeleportDestinationClientInfo)4