Package net.glowstone.block

Examples of net.glowstone.block.GlowBlockState


    @Override
    public GlowBlockState[] getTileEntities() {
        List<GlowBlockState> states = new ArrayList<>(tileEntities.size());
        for (TileEntity tileEntity : tileEntities.values()) {
            GlowBlockState state = tileEntity.getState();
            if (state != null) {
                states.add(state);
            }
        }
View Full Code Here


            if (!targetType.canOverride(target, face, holding)) {
                return;
            }
        }

        GlowBlockState newState = target.getState();

        PlayerBucketEmptyEvent event = EventFactory.callEvent(new PlayerBucketEmptyEvent(player, target, face, holding.getType(), holding));
        if (event.isCancelled()) {
            return;
        }

        liquid.placeBlock(player, newState, face, holding, clickedLoc);

        // perform the block change
        newState.update(true);

        // deduct from stack if not in creative mode
        if (player.getGameMode() != GameMode.CREATIVE) {
            holding.setType(Material.BUCKET);
        }
View Full Code Here

            if (dye.getColor() == DyeColor.BROWN && target.getType() == Material.LOG) {
                data = target.getState().getData();
                if (data instanceof Tree &&
                        ((Tree) data).getSpecies() == TreeSpecies.JUNGLE &&
                        target.getRelative(face).getType() == Material.AIR) {
                    final GlowBlockState state = target.getRelative(face).getState();
                    state.setType(Material.COCOA);
                    state.setData(new CocoaPlant(CocoaPlantSize.SMALL, face.getOppositeFace()));
                    state.update(true);

                    // deduct from stack if not in creative mode
                    if (player.getGameMode() != GameMode.CREATIVE) {
                        holding.setAmount(holding.getAmount() - 1);
                    }
View Full Code Here

    }

    @Override
    public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc) {
        if (target.getType() == soilType && target.getRelative(BlockFace.UP).getType() == Material.AIR) {
            final GlowBlockState state = target.getRelative(BlockFace.UP).getState();
            state.setType(cropsType);
            state.setRawData((byte) 0);
            state.update(true);

            // deduct from stack if not in creative mode
            if (player.getGameMode() != GameMode.CREATIVE) {
                holding.setAmount(holding.getAmount() - 1);
            }
View Full Code Here

    }

    @Override
    public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc) {
        if (target.getType() == soilType && target.getRelative(BlockFace.UP).getType() == Material.AIR) {
            final GlowBlockState state = target.getRelative(BlockFace.UP).getState();
            state.setType(cropsType);
            state.setRawData((byte) 0);
            state.update(true);

            // deduct from stack if not in creative mode
            if (player.getGameMode() != GameMode.CREATIVE) {
                holding.setAmount(holding.getAmount() - 1);
            }
View Full Code Here

        setDrops(new ItemStack(material));
    }

    @Override
    public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) {
        final GlowBlockState state = block.getState();
        final MaterialData data = state.getData();

        if (!(data instanceof Button)) {
            warnMaterialData(Button.class, data);
            return false;
        }

        final Button button = (Button) data;

        if (button.isPowered()) {
            return true;
        }

        button.setPowered(true);
        state.update();

        // todo: switch to block scheduling system when one is available
        (new BukkitRunnable() {
            @Override
            public void run() {
                button.setPowered(false);
                state.update();
            }
        }).runTaskLater(null, 20);

        return true;
    }
View Full Code Here

    public void afterPlace(GlowPlayer player, GlowBlock block, ItemStack holding) {
        if (block.getType() == Material.BED_BLOCK) {
            BlockFace direction = ((Bed) block.getState().getData()).getFacing();
            GlowBlock headBlock = block.getRelative(direction);
            headBlock.setType(Material.BED_BLOCK);
            GlowBlockState headBlockState = headBlock.getState();
            MaterialData data = headBlockState.getData();
            ((Bed) data).setHeadOfBed(true);
            ((Bed) data).setFacingDirection(direction);
            headBlockState.setData(data);
            headBlockState.update(true);
        }
    }
View Full Code Here

        setDrops(new ItemStack(Material.LEVER));
    }

    @Override
    public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) {
        final GlowBlockState state = block.getState();
        final MaterialData data = state.getData();

        if (!(data instanceof Lever)) {
            warnMaterialData(Lever.class, data);
            return false;
        }

        final Lever lever = (Lever) data;
        lever.setPowered(!lever.isPowered());
        state.update();
        return true;
    }
View Full Code Here

     * @param y the y-coordinate of this block
     * @param z the z-coordinate of this block
     * @param type the new type of this block
     */
    public void setType(World world, int x, int y, int z, Material type) {
        final GlowBlockState state = (GlowBlockState) world.getBlockAt(x, y, z).getState();
        state.setType(type);
        blockStateMap.put(world.getBlockAt(x, y, z).getLocation(), state);
    }
View Full Code Here

     * @param z the z-coordinate of this block
     * @param type the new type of this block
     * @param data the new MaterialData of this block
     */
    public void setTypeAndData(World world, int x, int y, int z, Material type, MaterialData data) {
        final GlowBlockState state = (GlowBlockState) world.getBlockAt(x, y, z).getState();
        state.setType(type);
        state.setData(data);
        blockStateMap.put(world.getBlockAt(x, y, z).getLocation(), state);
    }
View Full Code Here

TOP

Related Classes of net.glowstone.block.GlowBlockState

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.