Search in sources :

Example 1 with Coordinate

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

the class LiquidAbsorberTileEntity method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);
    int[] x = tagCompound.getIntArray("toscanx");
    int[] y = tagCompound.getIntArray("toscany");
    int[] z = tagCompound.getIntArray("toscanz");
    toscan.clear();
    for (int i = 0; i < x.length; i++) {
        toscan.add(new Coordinate(x[i], y[i], z[i]));
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate)

Example 2 with Coordinate

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

the class MaterialAbsorberTileEntity method checkStateServer.

@Override
protected void checkStateServer() {
    if (absorbing > 0 || blockID == -1) {
        timer--;
        if (timer <= 0) {
            timer = ABSORB_SPEED;
            Block b = isValidSourceBlock(new Coordinate(xCoord, yCoord - 1, zCoord));
            if (b != null) {
                int id = Block.blockRegistry.getIDForObject(b);
                if (blockID == -1) {
                    absorbing = DimletConstructionConfiguration.maxBlockAbsorbtion;
                    blockID = id;
                    meta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord);
                    toscan.clear();
                }
                toscan.add(new Coordinate(xCoord, yCoord - 1, zCoord));
            }
            if (!toscan.isEmpty()) {
                int r = worldObj.rand.nextInt(toscan.size());
                Iterator<Coordinate> iterator = toscan.iterator();
                Coordinate c = null;
                for (int i = 0; i <= r; i++) {
                    c = iterator.next();
                }
                toscan.remove(c);
                checkBlock(c, ForgeDirection.DOWN);
                checkBlock(c, ForgeDirection.UP);
                checkBlock(c, ForgeDirection.EAST);
                checkBlock(c, ForgeDirection.WEST);
                checkBlock(c, ForgeDirection.SOUTH);
                checkBlock(c, ForgeDirection.NORTH);
                Block block = blockMatches(c);
                if (block != null) {
                    RFToolsTools.playSound(worldObj, block.stepSound.getBreakSound(), xCoord, yCoord, zCoord, 1.0f, 1.0f);
                    worldObj.setBlockToAir(c.getX(), c.getY(), c.getZ());
                    absorbing--;
                    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
                }
            }
        }
        markDirty();
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate) Block(net.minecraft.block.Block)

Example 3 with Coordinate

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

the class BlockProtectors method readDestinationsFromNBT.

private void readDestinationsFromNBT(NBTTagCompound tagCompound) {
    NBTTagList lst = tagCompound.getTagList("blocks", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < lst.tagCount(); i++) {
        NBTTagCompound tc = lst.getCompoundTagAt(i);
        Coordinate c = new Coordinate(tc.getInteger("x"), tc.getInteger("y"), tc.getInteger("z"));
        int dim = tc.getInteger("dim");
        GlobalCoordinate gc = new GlobalCoordinate(c, dim);
        int id = tc.getInteger("id");
        protectorById.put(id, gc);
        protectorIdByCoordinate.put(gc, id);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 4 with Coordinate

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

the class BlockProtectorTileEntity method updateDestination.

/**
 * This method is called after putting down a protector that was earlier wrenched. We need to fix the data in
 * the destination.
 */
public void updateDestination() {
    BlockProtectors protectors = BlockProtectors.getProtectors(worldObj);
    GlobalCoordinate gc = new GlobalCoordinate(new Coordinate(xCoord, yCoord, zCoord), worldObj.provider.dimensionId);
    if (id == -1) {
        id = protectors.getNewId(gc);
        markDirty();
    } else {
        protectors.assignId(gc, id);
    }
    protectors.save(worldObj);
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) Coordinate(mcjty.lib.varia.Coordinate) GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate)

Example 5 with Coordinate

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

the class BlockProtectorTileEntity method toggleCoordinate.

// Toggle a coordinate to be protected or not. The coordinate given here is absolute.
public void toggleCoordinate(GlobalCoordinate c) {
    if (c.getDimension() != worldObj.provider.dimensionId) {
        // Wrong dimension. Don't do anything.
        return;
    }
    Coordinate relative = absoluteToRelative(c.getCoordinate());
    if (protectedBlocks.contains(relative)) {
        protectedBlocks.remove(relative);
    } else {
        protectedBlocks.add(relative);
    }
    markDirty();
    notifyBlockUpdate();
}
Also used : GlobalCoordinate(mcjty.lib.varia.GlobalCoordinate) 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