Package com.sk89q.craftbook.util

Examples of com.sk89q.craftbook.util.BlockVector


        if (in.readByte() != 0) throw new IOException("wrong version");

        int l = in.readInt();
        for (int j = 0; j < l; j++) {
            BlockVector v = new BlockVector(in.readInt(), in.readInt(), in.readInt());
            int[] data = new int[in.readInt()];
            for (int k = 0; k < data.length; k++) { if (in.readBoolean()) data[k] = in.readInt(); }
            worldData.put(v, data);
        }
        privatePersistentStorage.put(worldName, worldData);
View Full Code Here


            // Cauldron is 2 units deep
            if (BlockType.isLava(below)) {
                rootY++;
            }

            performCauldron(player, world, new BlockVector(x, rootY, z));
        }
    }
View Full Code Here

            close = w.getId(x, y - 1, z) != BlockType.FENCE;
        }

        // Recursively go to connected fence blocks of the same level
        // and 'close' or 'open' them
        toggleColumn(w, new BlockVector(x, y, z), close, visitedColumns, bag);

        return true;
    }
View Full Code Here

            // We will take the status we want to switch to from the torch
            // above the switch
            boolean on = aboveID != BlockType.TORCH;

            // Prevent spam
            BlockVector bvec = origin.toBlockVector();
            Long lastUse = recentLightToggles.remove(bvec);
            long now = System.currentTimeMillis();
            if (lastUse != null && now - lastUse < 500) {
                recentLightToggles.put(bvec, lastUse);
                return true;
View Full Code Here

    }

    public boolean onSignChange(Player p, Sign sp) {

        PlayerInterface player = new HmodPlayerImpl(p, w);
        BlockVector signPosition = new BlockVector(sp.getX(), sp.getY(), sp.getZ());
        SignInterface s = new HmodSignImpl(w, signPosition, sp);
        for (CraftBookDelegateListener l : main.signChangeListeners) {
            if (l.onSignChange(player, w, signPosition, s)) return true;
        }
        return false;
View Full Code Here

     * @param oldLevel
     * @param newLevel
     */
    public int onRedstoneChange(Block block, int oldLevel, int newLevel) {

        BlockVector v = new BlockVector(block.getX(), block.getY(), block.getZ());

        // Give the method a BlockVector instead of a Block
        boolean wasOn = oldLevel >= 1;
        boolean isOn = newLevel >= 1;
        boolean wasChange = wasOn != isOn;

        // For efficiency reasons, we're only going to consider changes between
        // off and on state, and ignore simple current changes (i.e. 15->13)
        if (!wasChange) {
            return newLevel;
        }

        int x = v.getBlockX();
        int y = v.getBlockY();
        int z = v.getBlockZ();

        int type = w.getId(x, y, z);

        // When this hook has been called, the level in the world has not
        // yet been updated, so we're going to do this very ugly thing of
View Full Code Here

    }

    public boolean onBlockPlace(Player p, Block pp, Block cp, Item itemInHand) {

        PlayerInterface player = new HmodPlayerImpl(p, w);
        BlockVector pv = new BlockVector(pp.getX(), pp.getY(), pp.getZ());
        BlockVector cv = new BlockVector(cp.getX(), cp.getY(), cp.getZ());
        for (CraftBookDelegateListener listener : main.blockPlaceListeners) {
            if (listener.onBlockPlace(w, player, pv, cv, itemInHand.getItemId()))
                return true;
        }
        return false;
View Full Code Here

    }

    public void onBlockRightClicked(Player p, Block cp, Item itemInHand) {

        PlayerInterface player = new HmodPlayerImpl(p, w);
        BlockVector cv = new BlockVector(cp.getX(), cp.getY(), cp.getZ());
        for (CraftBookDelegateListener listener : main.blockRightClickListeners) {
            listener.onBlockRightClicked(w, player, cv, itemInHand.getItemId());
        }
    }
View Full Code Here

    }

    public boolean onBlockDestroy(Player p, Block dp) {

        PlayerInterface player = new HmodPlayerImpl(p, w);
        BlockVector dv = new BlockVector(dp.getX(), dp.getY(), dp.getZ());
        for (CraftBookDelegateListener listener : main.blockDestroyedListeners) {
            if (listener.onBlockDestroy(w, player, dv, dp.getStatus()))
                return true;
        }
        return false;
View Full Code Here

    public BlockEntity getBlockEntity(int x, int y, int z) {

        ComplexBlock b = server.getComplexBlock(x, y, z);
        if (b == null) return null;
        else if (b instanceof Sign) return new HmodSignImpl(this, new BlockVector(x, y, z), (Sign) b);
        else if (b instanceof Chest) return new HmodChestImpl(this, new BlockVector(x, y, z), (Chest) b);
        else if (b instanceof DoubleChest) return new HmodChestImpl(this, new BlockVector(x, y, z), (DoubleChest) b);
        else return null;
    }
View Full Code Here

TOP

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

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.