Search in sources :

Example 46 with Coordinate

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

the class ScreenControllerTileEntity method getTags.

@Callback(doc = "Get a table of all tags supported by all connected screens", getter = true)
@Optional.Method(modid = "OpenComputers")
public Object[] getTags(Context context, Arguments args) throws Exception {
    List<String> tags = new ArrayList<String>();
    for (Coordinate screen : connectedScreens) {
        TileEntity te = worldObj.getTileEntity(screen.getX(), screen.getY(), screen.getZ());
        if (te instanceof ScreenTileEntity) {
            ScreenTileEntity screenTileEntity = (ScreenTileEntity) te;
            tags.addAll(screenTileEntity.getTags());
        }
    }
    return new Object[] { tags };
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Coordinate(mcjty.lib.varia.Coordinate) ArrayList(java.util.ArrayList) Callback(li.cil.oc.api.machine.Callback)

Example 47 with Coordinate

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

the class ScreenControllerTileEntity method detach.

public void detach() {
    for (Coordinate c : connectedScreens) {
        TileEntity te = worldObj.getTileEntity(c.getX(), c.getY(), c.getZ());
        if (te instanceof ScreenTileEntity) {
            ((ScreenTileEntity) te).setPower(false);
            ((ScreenTileEntity) te).setConnected(false);
        }
    }
    connectedScreens.clear();
    markDirty();
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Coordinate(mcjty.lib.varia.Coordinate)

Example 48 with Coordinate

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

the class ScreenControllerTileEntity method scan.

private void scan() {
    detach();
    int radius = 32 + (int) (getInfusedFactor() * 32);
    for (int y = yCoord - 16; y <= yCoord + 16; y++) {
        if (y >= 0 && y < 256) {
            for (int x = xCoord - radius; x <= xCoord + radius; x++) {
                for (int z = zCoord - radius; z <= zCoord + radius; z++) {
                    TileEntity te = worldObj.getTileEntity(x, y, z);
                    if (te instanceof ScreenTileEntity) {
                        if (!((ScreenTileEntity) te).isConnected()) {
                            connectedScreens.add(new Coordinate(x, y, z));
                            ((ScreenTileEntity) te).setConnected(true);
                        }
                    }
                }
            }
        }
    }
    markDirty();
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Coordinate(mcjty.lib.varia.Coordinate)

Example 49 with Coordinate

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

the class GuiRFMonitor method setSelectedBlock.

private void setSelectedBlock(int index) {
    if (index != -1) {
        Coordinate c = adjacentBlocks.get(index);
        tileEntity.setMonitor(c);
        RFToolsMessages.INSTANCE.sendToServer(new PacketContentsMonitor(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, c));
    } else {
        tileEntity.setInvalid();
        RFToolsMessages.INSTANCE.sendToServer(new PacketContentsMonitor(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, Coordinate.INVALID));
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate)

Example 50 with Coordinate

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

the class GuiRFMonitor 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)

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