Package com.sk89q.worldedit

Examples of com.sk89q.worldedit.BlockVector


            Extent extent = getExtent();

            final Set<BlockVector> blocks = new HashSet<BlockVector>();
            final Map<BlockVector, BaseBlock> blockTypes = new HashMap<BlockVector, BaseBlock>();
            for (Map.Entry<BlockVector, BaseBlock> entry : stage3) {
                final BlockVector pt = entry.getKey();
                blocks.add(pt);
                blockTypes.put(pt, entry.getValue());
            }

            while (!blocks.isEmpty()) {
                BlockVector current = blocks.iterator().next();
                if (!blocks.contains(current)) {
                    continue;
                }

                final Deque<BlockVector> walked = new LinkedList<BlockVector>();

                while (true) {
                    walked.addFirst(current);

                    assert (blockTypes.containsKey(current));

                    final BaseBlock baseBlock = blockTypes.get(current);

                    final int type = baseBlock.getType();
                    final int data = baseBlock.getData();

                    switch (type) {
                        case BlockID.WOODEN_DOOR:
                        case BlockID.IRON_DOOR:
                            if ((data & 0x8) == 0) {
                                // Deal with lower door halves being attached to the floor AND the upper half
                                BlockVector upperBlock = current.add(0, 1, 0).toBlockVector();
                                if (blocks.contains(upperBlock) && !walked.contains(upperBlock)) {
                                    walked.addFirst(upperBlock);
                                }
                            }
                            break;

                        case BlockID.MINECART_TRACKS:
                        case BlockID.POWERED_RAIL:
                        case BlockID.DETECTOR_RAIL:
                        case BlockID.ACTIVATOR_RAIL:
                            // Here, rails are hardcoded to be attached to the block below them.
                            // They're also attached to the block they're ascending towards via BlockType.getAttachment.
                            BlockVector lowerBlock = current.add(0, -1, 0).toBlockVector();
                            if (blocks.contains(lowerBlock) && !walked.contains(lowerBlock)) {
                                walked.addFirst(lowerBlock);
                            }
                            break;
                    }
View Full Code Here


        super(extent);
    }

    @Override
    public BaseBlock getLazyBlock(Vector position) {
        BlockVector blockVector = position.toBlockVector();
        CachedBlock lastBlock = this.lastBlock;
        if (lastBlock != null && lastBlock.position.equals(blockVector)) {
            return lastBlock.block;
        } else {
            BaseBlock block = super.getLazyBlock(position);
View Full Code Here

    public static LocalWorld getLocalWorld(World w) {
        return new BukkitWorld(w);
    }

    public static BlockVector toVector(Block block) {
        return new BlockVector(block.getX(), block.getY(), block.getZ());
    }
View Full Code Here

    public static BlockVector toVector(Block block) {
        return new BlockVector(block.getX(), block.getY(), block.getZ());
    }

    public static BlockVector toVector(BlockFace face) {
        return new BlockVector(face.getModX(), face.getModY(), face.getModZ());
    }
View Full Code Here

    public void add(Change change) {
        checkNotNull(change);

        if (change instanceof BlockChange) {
            BlockChange blockChange = (BlockChange) change;
            BlockVector position = blockChange.getPosition();
            previous.put(position, blockChange.getPrevious());
            current.put(position, blockChange.getCurrent());
        } else {
            super.add(change);
        }
View Full Code Here

        double x2 = Math.max(position.getX(), position2.getX());
        double y2 = Math.max(position.getY(), position2.getY());
        double z2 = Math.max(position.getZ(), position2.getZ());

        final BlockVector o1 = position1;
        final BlockVector o2 = position2;
        position1 = new BlockVector(x1, y1, z1);
        position2 = new BlockVector(x2, y2, z2);
        region.setPos1(position1);
        region.setPos2(position2);

        assert(region.contains(o1));
        assert(region.contains(o2));
View Full Code Here

        final short cacheEntry = cache[index];
        switch (cacheEntry) {
        case 0:
            // unknown, fetch material
            final BaseBlock material = getMaterial(x, y, z, pattern.next(new BlockVector(x, y, z)));
            if (material == null) {
                // outside
                cache[index] = -1;
                return null;
            }
View Full Code Here

                }

                values.put(entry.getKey(), entry.getValue());
            }

            BlockVector vec = new BlockVector(x, y, z);
            tileEntities.put(vec, values);
        }
    }
View Full Code Here

    private CompoundTag getBlockTileEntity(Vector position) throws DataException {
        if (tileEntities == null) {
            populateTileEntities();
        }

        Map<String, Tag> values = tileEntities.get(new BlockVector(position));
        if (values == null) {
            return null;
        }
        return new CompoundTag(values);
    }
View Full Code Here

        final Vector max = getMaximumPoint();
        final int centerY = getCenter().getBlockY();

        for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
            for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
                if (!contains(new BlockVector(x, centerY, z))) {
                    continue;
                }

                chunks.add(new BlockVector2D(
                    x >> ChunkStore.CHUNK_SHIFTS,
View Full Code Here

TOP

Related Classes of com.sk89q.worldedit.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.