Package com.sk89q.craftbook.util

Examples of com.sk89q.craftbook.util.ItemInfo


        return isValidGateBlock(sign, smallSearchSize, new ItemInfo(t), true);
    }

    public ItemInfo getGateBlock(ChangedSign sign, boolean smallSearchSize) {

        ItemInfo gateBlock = null;

        if (sign != null) {
            if(!sign.getLine(0).isEmpty()) {
                try {
                    return new ItemInfo(sign.getLine(0));
                } catch (Exception ignored) {
                }
            }

            int x = sign.getX();
            int y = sign.getY();
            int z = sign.getZ();

            if (smallSearchSize) {
                for (int x1 = x - 1; x1 <= x + 1; x1++) {
                    for (int y1 = y - 2; y1 <= y + 1; y1++) {
                        for (int z1 = z - 1; z1 <= z + 1; z1++) {
                            if (getFirstBlock(sign, sign.getSign().getBlock().getWorld().getBlockAt(x1, y1, z1), smallSearchSize) != null) {
                                gateBlock = new ItemInfo(getFirstBlock(sign, sign.getSign().getBlock().getWorld().getBlockAt(x1, y1, z1), smallSearchSize));
                            }
                        }
                    }
                }
            } else {
                for (int x1 = x - searchRadius; x1 <= x + searchRadius; x1++) {
                    for (int y1 = y - searchRadius; y1 <= y + searchRadius*2; y1++) {
                        for (int z1 = z - searchRadius; z1 <= z + searchRadius; z1++) {
                            if (getFirstBlock(sign, sign.getSign().getBlock().getWorld().getBlockAt(x1, y1, z1), smallSearchSize) != null) {
                                gateBlock = new ItemInfo(getFirstBlock(sign, sign.getSign().getBlock().getWorld().getBlockAt(x1, y1, z1), smallSearchSize));
                            }
                        }
                    }
                }
            }

            if(enforceType && gateBlock != null && gateBlock.getType() != Material.AIR && sign != null) {
                sign.setLine(0, gateBlock.toString());
                sign.update(false);
            }
        }

        return gateBlock;
View Full Code Here


        return gateBlock;
    }

    public Block getFirstBlock(ChangedSign sign, Block block, boolean smallSearchSize) {

        if (!isValidGateBlock(sign, smallSearchSize, new ItemInfo(block), false)) return null;

        return block;
    }
View Full Code Here

            if(maxY == -1) {
                int max = Math.min(block.getWorld().getMaxHeight()-1, block.getY() + remainingColumnHeight);
                for (int y1 = block.getY() + 1; y1 <= max; y1++) {
                    if(remainingColumnHeight <= 0) break;
                    if (isValidGateBlock(sign, smallSearchSize, new ItemInfo(block.getWorld().getBlockAt(block.getX(), y1, block.getZ())), true)) {
                        maxY = y1;
                        remainingColumnHeight --;
                    } else
                        break;
                }
View Full Code Here

            if(minY == -1) {
                int min = Math.max(0, block.getY() - remainingColumnHeight);
                for (int y = block.getY(); y >= min; y--) {
                    if(remainingColumnHeight <= 0) break;
                    if (canPassThrough(sign, smallSearchSize, block.getWorld().getBlockAt(block.getX(), y, block.getZ())) || isValidGateBlock(sign, smallSearchSize, new ItemInfo(block.getWorld().getBlockAt(block.getX(), y, block.getZ())), true)) {
                        minY = y;
                        remainingColumnHeight --;
                    } else
                        break;
                }
View Full Code Here

    @Override
    public void loadConfiguration (YAMLProcessor config, String path) {

        config.setComment(path + "block", "Sets the block that is the base of the teleport mechanic.");
        material = new ItemInfo(config.getString(path + "block", "EMERALD_BLOCK:0"));
    }
View Full Code Here

        Block s1 = block.getRelative(1, 0, 0);
        Block s3 = block.getRelative(-1, 0, 0);
        Block s2 = block.getRelative(0, 0, 1);
        Block s4 = block.getRelative(0, 0, -1);

        ItemInfo blockItem = cauldronBlock;

        // stop strange lava ids
        if (below == Material.STATIONARY_LAVA)
            below = Material.LAVA;
        if (below2 == Material.STATIONARY_LAVA)
            below2 = Material.LAVA;
        // Preliminary check so we don't waste CPU cycles
        return (below == Material.LAVA || below2 == Material.LAVA) && (blockItem.isSame(s1) || blockItem.isSame(s2) || blockItem.isSame(s3) || blockItem.isSame(s4));

    }
View Full Code Here

    @Override
    public void loadConfiguration (YAMLProcessor config, String path) {

        config.setComment(path + "block", "Sets the block that is the base of the reverse mechanic.");
        material = new ItemInfo(config.getString(path + "block", "WOOL:0"));
    }
View Full Code Here

        // Gotta start at a root Y then find our orientation
        int rootY = block.getY();

        Player p = ((BukkitPlayer)player).getPlayer();

        ItemInfo blockItem = cauldronBlock;

        // Used to store cauldron blocks -- walls are counted
        Map<Location, ItemInfo> visited = new HashMap<Location, ItemInfo>();

        // The following attempts to recursively find adjacent blocks so
View Full Code Here

        config.setComment(path + "allow-diagonal", "Allow pipes to work diagonally. Required for insulators to work.");
        pipesDiagonal = config.getBoolean(path + "allow-diagonal", false);

        config.setComment(path + "insulator-block", "When pipes work diagonally, this block allows the pipe to be insulated to not work diagonally.");
        pipeInsulator = new ItemInfo(config.getString(path + "insulator-block", "WOOL"));

        config.setComment(path + "stack-per-move", "This option stops the pipes taking the entire chest on power, and makes it just take a single stack.");
        pipeStackPerPull = config.getBoolean(path + "stack-per-move", true);

        config.setComment(path + "require-sign", "Requires pipes to have a [Pipe] sign connected to them. This is the only way to require permissions to make pipes.");
View Full Code Here

     *
     * @throws Cauldron.NotACauldronException
     */
    public void findCauldronContents(LocalPlayer player, World world, Block block, int minY, int maxY, Map<Location, ItemInfo> visited) {

        ItemInfo blockID = cauldronBlock;

        // Don't want to go too low or high
        if (block.getY() < minY) return;
        if (block.getY() > maxY) return;

        // There is likely a leak in the cauldron (or this isn't a cauldron)
        if (visited.size() > 24) {
            player.printError("mech.cauldron.leaky");
            return;
        }

        // Prevent infinite looping
        if (visited.containsKey(block.getLocation())) return;

        Material type = block.getType();

        // Make water work reliably
        if (type == Material.STATIONARY_WATER)
            type = Material.WATER;

        // Make lava work reliably
        if (type == Material.STATIONARY_LAVA)
            type = Material.LAVA;

        visited.put(block.getLocation(), new ItemInfo(type, block.getData()));

        // It's a wall -- we only needed to remember that we visited it but
        // we don't need to recurse
        if (type == blockID.getType()) return;

        // Must have a lava floor
        Block lavaPos = recurse(0, block.getY() - minY + 1, 0, block);
        if (world.getBlockTypeIdAt(lavaPos.getX(), lavaPos.getY(), lavaPos.getZ()) == BlockID.LAVA) {
            player.printError("mech.cauldron.no-lava");
View Full Code Here

TOP

Related Classes of com.sk89q.craftbook.util.ItemInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.