Package com.sk89q.worldedit.blocks

Examples of com.sk89q.worldedit.blocks.BaseBlock


    }

    @Nullable
    @Override
    public BaseBlock createFromId(int id) {
        return new BaseBlock(id);
    }
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;
            }

            short newCacheEntry = (short) (material.getType() | ((material.getData() + 1) << 8));
            if (newCacheEntry == 0) {
                // type and data 0
                newCacheEntry = -2;
            }

            cache[index] = newCacheEntry;
            return material;

        case -1:
            // outside
            return null;

        case -2:
            // type and data 0
            return new BaseBlock(0, 0);
        }

        return new BaseBlock(cacheEntry & 255, ((cacheEntry >> 8) - 1) & 15);
    }
View Full Code Here

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

            if (!hollow) {
                final BaseBlock material = getMaterial(x, y, z, pattern.next(position));
                if (material != null && editSession.setBlock(position, material)) {
                    ++affected;
                }

                continue;
            }

            final BaseBlock material = getMaterialCached(x, y, z, pattern);
            if (material == null) {
                continue;
            }

            boolean draw = false;
View Full Code Here

    @Override
    public boolean test(Vector vector) {
        Extent extent = getExtent();
        Collection<BaseBlock> blocks = getBlocks();
        BaseBlock lazyBlock = extent.getLazyBlock(vector);
        BaseBlock compare = new BaseBlock(lazyBlock.getType(), lazyBlock.getData());
        return Blocks.containsFuzzy(blocks, compare);
    }
View Full Code Here

    @Override
    public BaseBlock getBlock(Vector position) throws DataException {
        int id = getBlockID(position);
        int data = getBlockData(position);
        BaseBlock block;

        /*if (id == BlockID.WALL_SIGN || id == BlockID.SIGN_POST) {
            block = new SignBlock(id, data);
        } else if (id == BlockID.CHEST) {
            block = new ChestBlock(data);
        } else if (id == BlockID.FURNACE || id == BlockID.BURNING_FURNACE) {
            block = new FurnaceBlock(id, data);
        } else if (id == BlockID.DISPENSER) {
            block = new DispenserBlock(data);
        } else if (id == BlockID.MOB_SPAWNER) {
            block = new MobSpawnerBlock(data);
        } else if (id == BlockID.NOTE_BLOCK) {
            block = new NoteBlock(data);
        } else {*/
            block = new BaseBlock(id, data);
        //}

        CompoundTag tileEntity = getBlockTileEntity(position);
        if (tileEntity != null) {
            block.setNbtData(tileEntity);
        }

        return block;
    }
View Full Code Here

    }

    @Override
    public boolean test(Vector vector) {
        Extent extent = getExtent();
        BaseBlock lazyBlock = extent.getLazyBlock(vector);
        return !BlockType.canPassThrough(lazyBlock.getType(), lazyBlock.getData());
    }
View Full Code Here

                // Good, the chunk could be at least loaded

                // Now just copy blocks!
                for (Vector pos : entry.getValue()) {
                    try {
                        BaseBlock block = chunk.getBlock(pos);
                        editSession.setBlock(pos, block);
                    } catch (DataException e) {
                        // this is a workaround: just ignore for now
                    }
                }
View Full Code Here

        }
    }

    @Override
    public BaseBlock apply(Vector pos) {
        BaseBlock block = buffer.get(pos.toBlockVector());
        if (block != null) {
            return block;
        } else {
            return AIR;
        }
View Full Code Here

    }

    @Override
    public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
        if (blockBag != null) {
            BaseBlock lazyBlock = getExtent().getLazyBlock(position);
            int existing = lazyBlock.getType();
            final int type = block.getType();

            if (type > 0) {
                try {
                    blockBag.fetchPlacedBlock(type, 0);
                } catch (UnplaceableBlockException e) {
                    return false;
                } catch (BlockBagException e) {
                    if (!missingBlocks.containsKey(type)) {
                        missingBlocks.put(type, 1);
                    } else {
                        missingBlocks.put(type, missingBlocks.get(type) + 1);
                    }
                    return false;
                }
            }

            if (existing > 0) {
                try {
                    blockBag.storeDroppedBlock(existing, lazyBlock.getData());
                } catch (BlockBagException ignored) {
                }
            }
        }
View Full Code Here

     *
     * @return a pattern that places flora
     */
    public static Pattern getDesertPattern() {
        RandomPattern pattern = new RandomPattern();
        pattern.add(new BlockPattern(new BaseBlock(BlockID.DEAD_BUSH)), 30);
        pattern.add(new BlockPattern(new BaseBlock(BlockID.CACTUS)), 20);
        pattern.add(new BlockPattern(new BaseBlock(BlockID.AIR)), 300);
        return pattern;
    }
View Full Code Here

TOP

Related Classes of com.sk89q.worldedit.blocks.BaseBlock

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.