Package org.bukkit.block

Examples of org.bukkit.block.BlockState


                        }

                        // Send block "restore" events.
                        for (Map.Entry<Location,BlockState> entry : blocks.entrySet()) {
                            Location l   = entry.getKey();
                            BlockState b = entry.getValue();
                            int id       = b.getTypeId();
                            byte data    = b.getRawData();

                            p.sendBlockChange(l, id, data);
                        }
                    }
                }, 100);
View Full Code Here


   
    public RepairableAttachable(BlockState state)
    {
        super(state);
       
        BlockState attached;
        if (state.getData() instanceof Attachable)
            attached = state.getBlock().getRelative(((Attachable) state.getData()).getAttachedFace()).getState();
        else
            attached = state.getBlock().getRelative(BlockFace.DOWN).getState();
       
        x = attached.getX();
        y = attached.getY();
        z = attached.getZ();
       
        state.getBlock().setTypeId(1);
    }
View Full Code Here

    public RepairableDoor(BlockState state)
    {
        super(state);       
        other = state.getBlock().getRelative(BlockFace.UP).getState();
       
        BlockState attached = state.getBlock().getRelative(BlockFace.DOWN).getState();
        x = attached.getX();
        y = attached.getY();
        z = attached.getZ();
    }
View Full Code Here

    @Override
    public void storeContainerContents()
    {
        for (Location loc : region.getContainers()) {
            BlockState state = world.getBlockAt(loc).getState();
            if (state instanceof InventoryHolder) {
                containables.add(new RepairableContainer(state, false));
            }
        }
    }
View Full Code Here

    // Get rid of twice-stored double chests
    try {
      Iterator<BlockState> iter = states.iterator();
      while (iter.hasNext()) {
        BlockState next = iter.next();
        if (!(next instanceof Chest)) {
          continue;
        }
        DoubleChestInventory inventory = CommonUtil.tryCast(((Chest) next).getInventory(), DoubleChestInventory.class);
        if (inventory == null) {
View Full Code Here


        for (Location loc : locations) {

            Block source = copy_location.getBlock();
            BlockState sourceState = source.getState();
            Block update = destination.getBlock();

            update.setTypeIdAndData(source.getTypeId(), source.getData(), false);

            BlockState updateState = update.getState();

            // Note: only a BlockState, not a Block, is actually an instance
            // of InventoryHolder
            if (sourceState instanceof InventoryHolder) {

                ((InventoryHolder) updateState).getInventory()
                        .setContents(((InventoryHolder) sourceState).getInventory().getContents());
            }
            else if (sourceState instanceof Sign) {

                int n = 0;

                for (String line : ((Sign) sourceState).getLines()) {

                    ((Sign) updateState).setLine(n, line);
                    n++;
                }

                updateState.update();
            }


            // TODO: Account for Noteblock, Skull, Jukebox
View Full Code Here

        Block sign = location.getBlock();
        if (type != Type.AUTOMATIC
                || (sign.getType() != Material.WALL_SIGN
                && sign.getType() != Material.SIGN_POST))
            sign.setType(type == Type.WALL_SIGN ? Material.WALL_SIGN: Material.SIGN_POST);
        BlockState signState = sign.getState();

        Utilities.setSignLines((Sign) signState, text.toArray(4));
        if (direction != null)
            Utilities.setSignRotation(signState, direction);
        else if (type == Type.WALL_SIGN)
View Full Code Here

    public boolean clearContainerBlockContents(Vector pt) {
        Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
        if (block == null) {
            return false;
        }
        BlockState state = block.getState();
        if (!(state instanceof org.bukkit.inventory.InventoryHolder)) {
            return false;
        }

        org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state;
View Full Code Here

            dontExplode.add(block);
            if (zone.isBombBlock(block)) {
              // tnt doesn't get reset like normal blocks, gotta schedule a later reset just for the Bomb
              // structure's tnt block
              DeferredBlockResetsJob job = new DeferredBlockResetsJob();
              BlockState tnt = block.getState();
              tnt.setType(Material.TNT);
              job.add(tnt);
              War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job, 10);
            }
            inOneZone = true;
            break;
View Full Code Here

   * Retrieve the NBT tile entity that represents the given block.
   * @param state - the block state.
   * @return The NBT compound, or NULL if the state doesn't have a tile entity.
   */
  public static NbtCompound readBlockState(Block block) {
     BlockState state = block.getState();
     TileEntityAccessor<BlockState> accessor = TileEntityAccessor.getAccessor(state);
    
     return accessor != null ? accessor.readBlockState(state) : null;
  }
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.