Search in sources :

Example 96 with Coordinate

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

the class ItemStackPlusScreenModule method setupCoordinateFromNBT.

@Override
protected void setupCoordinateFromNBT(NBTTagCompound tagCompound, int dim, int x, int y, int z) {
    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 97 with Coordinate

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

the class ShieldBlockTileEntity method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);
    camoId = tagCompound.getInteger("camoId");
    hasTe = tagCompound.getInteger("hasTe");
    if (camoId == -1) {
        block = null;
    } else {
        block = Block.getBlockById(camoId);
    }
    damageBits = tagCompound.getInteger("damageBits");
    collisionData = tagCompound.getInteger("collisionData");
    shieldColor = tagCompound.getInteger("shieldColor");
    if (shieldColor == 0) {
        shieldColor = 0x96ffc8;
    }
    int sx = tagCompound.getInteger("shieldX");
    int sy = tagCompound.getInteger("shieldY");
    int sz = tagCompound.getInteger("shieldZ");
    shieldBlock = new Coordinate(sx, sy, sz);
    if (worldObj != null && worldObj.isRemote) {
        // For some reason this is needed to force rendering on the client when apply is pressed.
        worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate)

Example 98 with Coordinate

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

the class AbstractShieldBlock method checkEntityCD.

private boolean checkEntityCD(World world, int x, int y, int z, String filterName) {
    ShieldBlockTileEntity shieldBlockTileEntity = (ShieldBlockTileEntity) world.getTileEntity(x, y, z);
    Coordinate shieldBlock = shieldBlockTileEntity.getShieldBlock();
    if (shieldBlock != null) {
        ShieldTEBase shieldTileEntity = (ShieldTEBase) world.getTileEntity(shieldBlock.getX(), shieldBlock.getY(), shieldBlock.getZ());
        if (shieldTileEntity != null) {
            List<ShieldFilter> filters = shieldTileEntity.getFilters();
            for (ShieldFilter filter : filters) {
                if (DefaultFilter.DEFAULT.equals(filter.getFilterName())) {
                    return (filter.getAction() & ShieldFilter.ACTION_SOLID) != 0;
                } else if (filterName.equals(filter.getFilterName())) {
                    return (filter.getAction() & ShieldFilter.ACTION_SOLID) != 0;
                }
            }
        }
    }
    return false;
}
Also used : Coordinate(mcjty.lib.varia.Coordinate)

Example 99 with Coordinate

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

the class ShieldTEBase method addToTodoCornered.

private void addToTodoCornered(Set<Coordinate> coordinateSet, Deque<Coordinate> todo, Coordinate coordinate, int meta) {
    int x = coordinate.getX();
    int y = coordinate.getY();
    int z = coordinate.getZ();
    for (int xx = x - 1; xx <= x + 1; xx++) {
        for (int yy = y - 1; yy <= y + 1; yy++) {
            for (int zz = z - 1; zz <= z + 1; zz++) {
                if (xx != x || yy != y || zz != z) {
                    if (yy >= 0 && yy < worldObj.getHeight()) {
                        Coordinate c = new Coordinate(xx, yy, zz);
                        if (!coordinateSet.contains(c)) {
                            if (ShieldSetup.shieldTemplateBlock.equals(worldObj.getBlock(xx, yy, zz))) {
                                int m = worldObj.getBlockMetadata(xx, yy, zz);
                                if (m == meta) {
                                    if (!todo.contains(c)) {
                                        todo.addLast(c);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Coordinate(mcjty.lib.varia.Coordinate)

Example 100 with Coordinate

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

the class ShieldTEBase method selectBlock.

@Override
public void selectBlock(EntityPlayer player, int x, int y, int z) {
    if (!shieldComposed) {
        Logging.message(player, EnumChatFormatting.YELLOW + "Shield is not composed. Nothing happens!");
        return;
    }
    float squaredDistance = getCoordinate().squaredDistance(x, y, z);
    if (squaredDistance > ShieldConfiguration.maxDisjointShieldDistance * ShieldConfiguration.maxDisjointShieldDistance) {
        Logging.message(player, EnumChatFormatting.YELLOW + "This template is too far to connect to the shield!");
        return;
    }
    Block origBlock = worldObj.getBlock(x, y, z);
    Coordinate c = new Coordinate(x, y, z);
    if (origBlock == ShieldSetup.shieldTemplateBlock) {
        if (isShapedShield()) {
            Logging.message(player, EnumChatFormatting.YELLOW + "You cannot add template blocks to a shaped shield (using a shape card)!");
            return;
        }
        Set<Coordinate> templateBlocks = new HashSet<Coordinate>();
        findTemplateBlocks(templateBlocks, worldObj.getBlockMetadata(x, y, z), false, c);
        int[] camoId = calculateCamoId();
        int cddata = calculateShieldCollisionData();
        int damageBits = calculateDamageBits();
        Block block = calculateShieldBlock(damageBits);
        for (Coordinate templateBlock : templateBlocks) {
            RelCoordinate relc = new RelCoordinate(templateBlock.getX() - xCoord, templateBlock.getY() - yCoord, templateBlock.getZ() - zCoord);
            shieldBlocks.add(relc);
            updateShieldBlock(camoId, cddata, damageBits, block, relc);
        }
    } else if (origBlock instanceof AbstractShieldBlock) {
        shieldBlocks.remove(new RelCoordinate(c.getX() - xCoord, c.getY() - yCoord, c.getZ() - zCoord));
        if (isShapedShield()) {
            worldObj.setBlockToAir(x, y, z);
        } else {
            worldObj.setBlock(x, y, z, ShieldSetup.shieldTemplateBlock, templateMeta, 2);
        }
    } else {
        Logging.message(player, EnumChatFormatting.YELLOW + "The selected shield can't do anything with this block!");
        return;
    }
    markDirty();
    notifyBlockUpdate();
}
Also used : Coordinate(mcjty.lib.varia.Coordinate) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock)

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