Package org.bukkit.block

Examples of org.bukkit.block.BlockState


        int dropMultiplier = getDropMultiplier();

        float debrisYield = yield - debrisReduction;

        for (Block block : blockList) {
            BlockState blockState = block.getState();

            if (BlockUtils.isOre(blockState)) {
                ores.add(blockState);
            }
            else {
                debris.add(blockState);
            }
        }

        for (BlockState blockState : ores) {
            if (Misc.getRandom().nextFloat() < (yield + oreBonus)) {
                if (!mcMMO.getPlaceStore().isTrue(blockState)) {
                    xp += Mining.getBlockXp(blockState);
                }

                Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1)); // Initial block that would have been dropped

                if (!mcMMO.getPlaceStore().isTrue(blockState)) {
                    for (int i = 1; i < dropMultiplier; i++) {
                        Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
                    }
                }
            }
        }

        if (debrisYield > 0) {
            for (BlockState blockState : debris) {
                if (Misc.getRandom().nextFloat() < debrisYield) {
                    Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
                }
            }
        }

        applyXpGain(xp, XPGainReason.PVE);
View Full Code Here


    public void onPlayerInteract(PlayerInteractEvent event) {
        final Player player = event.getPlayer();
        if (!this.plugin.chestFakeInUse(player.getName()) && !player.isSneaking() && (event.getAction() == Action.RIGHT_CLICK_BLOCK) && this.plugin.getManager().isVanished(event.getPlayer()) && VanishPerms.canReadChestsSilently(event.getPlayer())) {
            final Block block = event.getClickedBlock();
            Inventory inventory = null;
            final BlockState blockState = block.getState();
            boolean fake = false;
            switch (block.getType()) {
                case TRAPPED_CHEST:
                case CHEST:
                    final Chest chest = (Chest) blockState;
View Full Code Here

                    return increaseSnow(snow.getRelative(0,-1,0), disperse);
            }

            if (freezeWater && (snow.getRelative(0, -1, 0).getType() == Material.WATER || snow.getRelative(0, -1, 0).getType() == Material.STATIONARY_WATER)) {
                if(snow.getRelative(0, -1, 0).getData() == 0) {
                    BlockState state = snow.getRelative(0, -1, 0).getState();
                    state.setType(Material.ICE);
                    if(ProtectionUtil.canBlockForm(state.getBlock(), state))
                        snow.getRelative(0, -1, 0).setType(Material.ICE);
                } else snow.getRelative(0, -1, 0).setType(Material.AIR);
            } else if(snow.getRelative(0, -1, 0).getType() == Material.WATER || snow.getRelative(0, -1, 0).getType() == Material.STATIONARY_WATER) {
                return true; //Still return true, pretend it's actually succeeded.
            }
View Full Code Here

        player.print("circuits.pipes.create");
    }

    public static ChangedSign getSignOnPiston(Block block) {

        BlockState state = block.getState();
        BlockFace facing = BlockFace.SELF;
        if(state.getData() instanceof Directional)
            facing = ((Directional) state.getData()).getFacing();

        for(BlockFace face : LocationUtil.getDirectFaces()) {

            if(face == facing || !SignUtil.isSign(block.getRelative(face)))
                continue;
View Full Code Here

                List<BlockFace> faces = new ArrayList<BlockFace>(Arrays.asList(new BlockFace[]{BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH}));
                Collections.shuffle(faces, CraftBookPlugin.inst().getRandom());
                for(BlockFace face : faces) {
                    if(block.getRelative(face).getType() == Material.LOG && ((Tree)block.getRelative(face).getState().getData()).getSpecies() == TreeSpecies.JUNGLE) {
                        block.setTypeIdAndData(Material.COCOA.getId(), (byte) 0, true);
                        BlockState state = block.getState();
                        ((CocoaPlant)state.getData()).setFacingDirection(face);
                        state.update();
                        return true;
                    }
                }
                return false;
            default:
View Full Code Here

     * @param from The from block.
     * @param to   The block the data is being moved to.
     */
    public boolean copyData(Block from, Block to) {

        BlockState toState = to.getState();
        BlockState fromState = from.getState();

        if (fromState instanceof DoubleChest || toState instanceof DoubleChest) return false;

        int type = from.getTypeId();
        byte data = from.getData();

        ItemStack[] oldInventory = null;
        if (fromState instanceof InventoryHolder) {
            oldInventory = ((InventoryHolder) fromState).getInventory().getContents().clone();
            ((InventoryHolder) fromState).getInventory().clear();
            fromState.update();
            from.setTypeId(0);
        }
        to.setTypeIdAndData(type, data, true);
        if (to.getType() == Material.STONE_BUTTON || to.getType() == Material.WOOD_BUTTON) {
            if ((to.getData() & 0x8) == 0x8) {
View Full Code Here

            final File file = new File(getGenerationFolder(), "IC-Pages/");
            if(!file.exists())
                file.mkdir();

            BlockState oldState = Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0).getState();
            Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0).setType(Material.WALL_SIGN);

            CraftBookPlugin.inst().createDefaultConfiguration(new File(getGenerationFolder(), "ic-config.yml"), "ic-config.yml");
            ICConfiguration icConfiguration = new ICConfiguration(new YAMLProcessor(new File(getGenerationFolder(), "ic-config.yml"), true, YAMLFormat.EXTENDED), CraftBookPlugin.logger());

            icConfiguration.load();

            int missingComments = 0;

            final Set<String> missingDocuments = new HashSet<String>();

            for(RegisteredICFactory ric : ICManager.inst().getICList()) {

                PrintWriter writer = new PrintWriter(new File(file, ric.getId() + ".txt"), "UTF-8");

                IC ic = ric.getFactory().create(null);

                writer.println("[[../Integrated_circuits#IC_Types_List|< Return to ICs]]");
                writer.println();

                for(ICFamily family : ric.getFamilies()) {
                    if(family instanceof FamilyAISO) continue;
                    writer.println("{{" + family.getName() + "|id=" + ric.getId() + "|name=" + ic.getTitle() + "}}");
                }

                if(ric.getFactory().getLongDescription() == null || ric.getFactory().getLongDescription().length == 0 || ric.getFactory().getLongDescription()[0].equals("Missing Description")) {
                    CraftBookPlugin.logger().info("Missing Long Description for: " + ric.getId());
                    missingDocuments.add(ric.getId());
                }

                for(String line : ric.getFactory().getLongDescription())
                    writer.println(line);

                writer.println();
                writer.println("== Sign parameters ==");
                writer.println("# " + ic.getSignTitle());
                writer.println("# [" + ric.getId() + "]");
                for(String line : ric.getFactory().getLineHelp()) {
                    if(line == null) line = "Blank";

                    if(line.contains("{") && line.contains("}")) line = StringUtils.replace(StringUtils.replace(line, "}", "</span>''"), "{", "''<span style='color:#808080'>"); //Optional Syntax.

                    if(line.contains("SearchArea")) line = StringUtils.replace(line, "SearchArea", "[[../Search_Area|Search Area]]");
                    if(line.contains("ItemSyntax")) line = StringUtils.replace(line, "ItemSyntax", "[[../Item_Syntax|Item Syntax]]");
                    if(line.contains("PlayerType")) line = StringUtils.replace(line, "PlayerType", "[[../Player_Type|Player Type]]");
                    writer.println("# " + line);
                }

                writer.println();
                writer.println("== Pins ==");

                writer.println();
                writer.println("=== Input ===");
                int pins = 0;

                ChipState state = ric.getFamilies()[0].detect(BukkitUtil.toWorldVector(Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0)), BukkitUtil.toChangedSign(Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0)));

                for(String pin : ric.getFactory().getPinDescription(state)) {

                    if(pins == state.getInputCount()) {
                        writer.println();
                        writer.println("=== Output ===");
                    }

                    writer.println("# " + (pin == null ? "Nothing" : pin));

                    if(pin == null) {
                        CraftBookPlugin.logger().info("Missing pin: " + pins + " for IC: " + ric.getId());
                        missingDocuments.add(ric.getId());
                    }

                    pins++;
                }

                writer.println();

                if(ric.getFactory() instanceof ConfigurableIC) {

                    writer.println("== Configuration ==");
                    writer.println();
                    writer.println("{| class=\"wiki-table sortable\"");
                    writer.println("|-");
                    writer.println("! Configuration Node and Path");
                    writer.println("! Default Value");
                    writer.println("! Effect");

                    String path = "ics." + ric.getId();

                    for(String key : icConfiguration.config.getKeys(path)) {
                        if(icConfiguration.config.getProperty(path + "." + key) != null && !(icConfiguration.config.getProperty(path + "." + key) instanceof Map)) {
                            writer.println("|-");
                            writer.println("| " + path + "." + key);
                            writer.println("| " + String.valueOf(icConfiguration.config.getProperty(path + "." + key)));
                            String comment = icConfiguration.config.getComment(path + "." + key);
                            if(comment == null) {
                                System.out.println("[WARNING] Key " + path + "." + key + " is missing a comment!");
                                missingComments++;
                                missingDocuments.add(ric.getId());
                                comment = "";
                            }
                            if(!comment.trim().isEmpty()) comment = comment.trim().substring(2);
                            writer.println("| " + comment);
                        }
                    }

                    writer.println("|}");
                    writer.println();
                }

                if(ric.getFactory() instanceof CommandIC) {

                    writer.println("== Commands ==");
                    writer.println();

                    writer.println("{| class=\"wiki-table\"");
                    writer.println("! Command");
                    writer.println("! Permission");
                    writer.println("! Description");
                    for(String[] bits : ((CommandIC) ric.getFactory()).getCommandInformation()) {
                        writer.println("|-");
                        writer.println("| /ic ic " + ric.getId().toLowerCase() + " " + bits[0]);
                        for(int i = 1; i < bits.length; i++)
                            writer.println("| " + bits[i]);
                    }
                    writer.println("|}");
                    writer.println();
                }


                writer.print("[[Category:IC]]");
                for(ICFamily family : ric.getFamilies())
                    writer.print("[[Category:" + family.getName() + "]]");
                writer.close();
            }

            System.out.println(missingComments + " Comments Are Missing");

            oldState.update(true);

            if(upload) {

                Bukkit.getScheduler().runTaskAsynchronously(CraftBookPlugin.inst(), new Runnable() {
View Full Code Here

        SurvivalGames.debug(w + " " + x1 + " " + x2 + " " + z1 + " " + z2 + " " + y1 + " " + usingx);
        int dir = new Location(w, x1, y1, z1).getBlock().getData();
        if (usingx) {
            for (int a = Math.max(x1, x2); a >= Math.min(x1, x2); a--) {
                Location l = new Location(w, a, y1, z1);
                BlockState b = l.getBlock().getState();
                if (b instanceof Sign) {
                    signs.add((Sign) b);
                    LobbyManager.lobbychunks.add(b.getChunk());
                    SurvivalGames.debug("usingx - " + b.getLocation().toString());
                } else {
                    SurvivalGames.debug("Not a sign" + b.getType().toString());
                    return false;
                }
            }
        } else {
            for (int a = Math.min(z1, z2); a <= Math.max(z1, z2); a++) {
              SurvivalGames.debug(a);
                Location l = new Location(w, x1, y1, a);
                BlockState b = l.getBlock().getState();
                if (b instanceof Sign) {
                    signs.add((Sign) b);
                    LobbyManager.lobbychunks.add(b.getChunk());
                    SurvivalGames.debug("notx - " + b.getLocation().toString());
                } else {
                  SurvivalGames.debug("Not a sign" + b.getType().toString());
                    return false;
                }
            }
        }
        SurvivalGames.debug("dir: " + dir);
View Full Code Here

        signs = new Sign[vdiff][hdiff];
        for (int y = vdiff - 1; y >= 0; y--) {
            for (int x = hdiff - 1; x >= 0; x--) {


                BlockState b = p.getServer().getWorld(SettingsManager.getInstance().getSystemConfig().getString("sg-system.lobby.sign.world")).getBlockAt(l).getState();
                lobbychunks.add(b.getChunk());
                if (b instanceof Sign) {
                    signs[y][x] = (Sign) b;
                }
                if (usingx) l = l.add(inc, 0, 0);
                else l = l.add(0, 0, inc);
View Full Code Here

  private Random rand = new Random();
 
    @EventHandler(priority = EventPriority.HIGHEST)
    public void ChestListener(PlayerInteractEvent e){
      if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
        BlockState clicked = e.getClickedBlock().getState();
        if(clicked instanceof Chest || clicked instanceof DoubleChest){
          int gameid = GameManager.getInstance().getPlayerGameId(e.getPlayer());
          if(gameid != -1){
            Game game = GameManager.getInstance().getGame(gameid);
            if(game.getMode() == GameMode.INGAME){
View Full Code Here

TOP

Related Classes of org.bukkit.block.BlockState

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.