Search in sources :

Example 56 with Coordinate

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

the class StorageScannerTileEntity method advanceCurrent.

// Advance the 'cur' index to the next block. Return false when done.
// When done 'scanning' will be set to false as well.
private boolean advanceCurrent() {
    Coordinate c = cur.getCoordinate();
    int cx = c.getX();
    int cy = c.getY();
    int cz = c.getZ();
    cx++;
    Coordinate lo = c1.getCoordinate();
    Coordinate up = c2.getCoordinate();
    if (cx > up.getX()) {
        cx = lo.getX();
        cy++;
        if (cy > up.getY()) {
            cy = lo.getY();
            cz++;
            if (cz > up.getZ()) {
                scanning.setValue(false);
                notifyBlockUpdate();
                return false;
            }
        }
    }
    cur.setCoordinate(new Coordinate(cx, cy, cz));
    notifyBlockUpdate();
    return true;
}
Also used : Coordinate(mcjty.lib.varia.Coordinate) SyncedCoordinate(mcjty.lib.entity.SyncedCoordinate)

Example 57 with Coordinate

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

the class StorageScannerTileEntity method checkInventoryStatus.

private void checkInventoryStatus(int cx, int cy, int cz) {
    TileEntity tileEntity = worldObj.getTileEntity(cx, cy, cz);
    if (tileEntity instanceof IInventory) {
        IInventory inventory = (IInventory) tileEntity;
        if (inventory.getSizeInventory() > 0) {
            inventories.add(new InvBlockInfo(new Coordinate(cx, cy, cz), inventory.getSizeInventory()));
            notifyBlockUpdate();
        }
    }
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) Coordinate(mcjty.lib.varia.Coordinate) SyncedCoordinate(mcjty.lib.entity.SyncedCoordinate)

Example 58 with Coordinate

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

the class DialingDeviceTileEntity method execute.

@Override
public boolean execute(EntityPlayerMP playerMP, String command, Map<String, Argument> args) {
    boolean rc = super.execute(playerMP, command, args);
    if (rc) {
        return rc;
    }
    if (CMD_FAVORITE.equals(command)) {
        String player = args.get("player").getString();
        Coordinate receiver = args.get("receiver").getCoordinate();
        int dimension = args.get("dimension").getInteger();
        boolean favorite = args.get("favorite").getBoolean();
        changeFavorite(player, receiver, dimension, favorite);
        return true;
    } else if (CMD_SHOWFAVORITE.equals(command)) {
        boolean favorite = args.get("favorite").getBoolean();
        setShowOnlyFavorites(favorite);
        return true;
    }
    return false;
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate)

Example 59 with Coordinate

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

the class DialingDeviceTileEntity method searchTransmitters.

public List<TransmitterInfo> searchTransmitters() {
    int x = xCoord;
    int y = yCoord;
    int z = zCoord;
    int hrange = TeleportConfiguration.horizontalDialerRange;
    int vrange = TeleportConfiguration.verticalDialerRange;
    List<TransmitterInfo> transmitters = new ArrayList<TransmitterInfo>();
    for (int dy = -vrange; dy <= vrange; dy++) {
        int yy = y + dy;
        if (yy >= 0 && yy < worldObj.getHeight()) {
            for (int dz = -hrange; dz <= hrange; dz++) {
                int zz = z + dz;
                for (int dx = -hrange; dx <= hrange; dx++) {
                    int xx = x + dx;
                    if (dx != 0 || dy != 0 || dz != 0) {
                        Coordinate c = new Coordinate(xx, yy, zz);
                        TileEntity tileEntity = worldObj.getTileEntity(xx, yy, zz);
                        if (tileEntity != null) {
                            if (tileEntity instanceof MatterTransmitterTileEntity) {
                                MatterTransmitterTileEntity matterTransmitterTileEntity = (MatterTransmitterTileEntity) tileEntity;
                                transmitters.add(new TransmitterInfo(c, matterTransmitterTileEntity.getName(), matterTransmitterTileEntity.getTeleportDestination()));
                            }
                        }
                    }
                }
            }
        }
    }
    return transmitters;
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) ArrayList(java.util.ArrayList)

Example 60 with Coordinate

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

the class DialingDeviceTileEntity method dialOnce.

@Callback(doc = "First parameter is a table describing the transmitter ('x', 'y', and 'z'). The second parameter is a table describing the receiver ('dim', 'x', 'y', and 'z'). This method will dial the transmitter to the receiver (dial once mode)")
@Optional.Method(modid = "OpenComputers")
public Object[] dialOnce(Context context, Arguments args) throws Exception {
    Map transmitter = args.checkTable(0);
    Map receiver = args.checkTable(1);
    if (!transmitter.containsKey("x") || !transmitter.containsKey("y") || !transmitter.containsKey("z")) {
        throw new IllegalArgumentException("Transmitter map doesn't contain the right x,y,z coordinate!");
    }
    if (!receiver.containsKey("x") || !receiver.containsKey("y") || !receiver.containsKey("z")) {
        throw new IllegalArgumentException("Receiver map doesn't contain the right x,y,z coordinate!");
    }
    if (!receiver.containsKey("dim")) {
        throw new IllegalArgumentException("Receiver map doesn't contain the right dimension!");
    }
    Coordinate transC = new Coordinate(((Double) transmitter.get("x")).intValue(), ((Double) transmitter.get("y")).intValue(), ((Double) transmitter.get("z")).intValue());
    int transDim = worldObj.provider.dimensionId;
    Coordinate recC = new Coordinate(((Double) receiver.get("x")).intValue(), ((Double) receiver.get("y")).intValue(), ((Double) receiver.get("z")).intValue());
    int recDim = ((Double) receiver.get("dim")).intValue();
    int result = dial(null, transC, transDim, recC, recDim, true);
    return new Object[] { result };
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) HashMap(java.util.HashMap) Map(java.util.Map) Callback(li.cil.oc.api.machine.Callback)

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