Search in sources :

Example 36 with Coordinate

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

the class PacketConnectedBlocksReady method fromBytes.

@Override
public void fromBytes(ByteBuf buf) {
    minx = buf.readInt();
    miny = buf.readInt();
    minz = buf.readInt();
    int size = buf.readInt();
    blockInfoMap = new HashMap<Coordinate, BlockInfo>();
    for (int i = 0; i < size; i++) {
        Coordinate coordinate = new Coordinate(buf.readShort() + minx, buf.readShort() + miny, buf.readShort() + minz);
        BlockInfo blockInfo = new BlockInfo(coordinate, buf.readInt(), buf.readInt());
        blockInfoMap.put(coordinate, blockInfo);
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate) BlockInfo(mcjty.rftools.BlockInfo)

Example 37 with Coordinate

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

the class ScreenControllerTileEntity method clearText.

private Object[] clearText(String tag) {
    for (Coordinate screen : connectedScreens) {
        TileEntity te = worldObj.getTileEntity(screen.getX(), screen.getY(), screen.getZ());
        if (te instanceof ScreenTileEntity) {
            ScreenTileEntity screenTileEntity = (ScreenTileEntity) te;
            List<ComputerScreenModule> computerScreenModules = screenTileEntity.getComputerModules(tag);
            if (computerScreenModules != null) {
                for (ComputerScreenModule screenModule : computerScreenModules) {
                    screenModule.clearText();
                }
            }
        }
    }
    return null;
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Coordinate(mcjty.lib.varia.Coordinate) ComputerScreenModule(mcjty.rftools.blocks.screens.modules.ComputerScreenModule)

Example 38 with Coordinate

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

the class ScreenControllerTileEntity method getScreens.

@Callback(doc = "Get a table with coordinates (every coordinate is a table indexed with 'x', 'y', and 'z') for all connected screens", getter = true)
@Optional.Method(modid = "OpenComputers")
public Object[] getScreens(Context context, Arguments args) throws Exception {
    List<Map<String, Integer>> result = new ArrayList<Map<String, Integer>>();
    for (Coordinate screen : connectedScreens) {
        Map<String, Integer> coordinate = new HashMap<String, Integer>();
        coordinate.put("x", screen.getX());
        coordinate.put("y", screen.getY());
        coordinate.put("z", screen.getZ());
        result.add(coordinate);
    }
    return new Object[] { result };
}
Also used : Coordinate(mcjty.lib.varia.Coordinate) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) Callback(li.cil.oc.api.machine.Callback)

Example 39 with Coordinate

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

the class ScreenControllerTileEntity method addText.

private Object[] addText(String tag, String text, int color) {
    for (Coordinate screen : connectedScreens) {
        TileEntity te = worldObj.getTileEntity(screen.getX(), screen.getY(), screen.getZ());
        if (te instanceof ScreenTileEntity) {
            ScreenTileEntity screenTileEntity = (ScreenTileEntity) te;
            List<ComputerScreenModule> computerScreenModules = screenTileEntity.getComputerModules(tag);
            if (computerScreenModules != null) {
                for (ComputerScreenModule screenModule : computerScreenModules) {
                    screenModule.addText(text, color);
                }
            }
        }
    }
    return null;
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Coordinate(mcjty.lib.varia.Coordinate) ComputerScreenModule(mcjty.rftools.blocks.screens.modules.ComputerScreenModule)

Example 40 with Coordinate

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

the class FluidBarScreenModule method setupFromNBT.

@Override
public void setupFromNBT(NBTTagCompound tagCompound, int dim, int x, int y, int z) {
    if (tagCompound != null) {
        helper.setShowdiff(tagCompound.getBoolean("showdiff"));
        coordinate = Coordinate.INVALID;
        if (tagCompound.hasKey("monitorx")) {
            this.dim = tagCompound.getInteger("dim");
            if (dim == this.dim) {
                Coordinate c = new Coordinate(tagCompound.getInteger("monitorx"), tagCompound.getInteger("monitory"), tagCompound.getInteger("monitorz"));
                int dx = Math.abs(c.getX() - x);
                int dy = Math.abs(c.getY() - y);
                int dz = Math.abs(c.getZ() - z);
                if (dx <= 64 && dy <= 64 && dz <= 64) {
                    coordinate = c;
                }
            }
        }
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate)

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