org.bukkit.block.Block.getBlockData()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(330)

本文整理了Java中org.bukkit.block.Block.getBlockData()方法的一些代码示例,展示了Block.getBlockData()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getBlockData()方法的具体详情如下:
包路径:org.bukkit.block.Block
类名称:Block
方法名:getBlockData

Block.getBlockData介绍

暂无

代码示例

代码示例来源:origin: EngineHub/WorldEdit

@Override
public com.sk89q.worldedit.world.block.BlockState getBlock(BlockVector3 position) {
  Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
  return BukkitAdapter.adapt(bukkitBlock.getBlockData());
}

代码示例来源:origin: EngineHub/WorldEdit

@Override
  public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
    Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ());
    if (block == null) {
      player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData());
    } else {
      player.sendBlockChange(loc, BukkitAdapter.adapt(block));
      if (block instanceof BaseBlock && ((BaseBlock) block).hasNbtData()) {
        BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
        if (adapter != null) {
          adapter.sendFakeNBT(player, pos, ((BaseBlock) block).getNbtData());
          if (block.getBlockType() == BlockTypes.STRUCTURE_BLOCK) {
            adapter.sendFakeOP(player);
          }
        }
      }
    }
  }
}

代码示例来源:origin: ChestShop-authors/ChestShop-3

/**
 * Checks if the block is a chest
 *
 * @param block Block to check
 * @return Is this block a chest?
 */
public static boolean isChest(Block block) {
  return block.getBlockData() instanceof org.bukkit.block.data.type.Chest;
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * Checks whether a door is open.
 *
 * @param door the door block
 * @return true or false
 */
public static boolean isDoorOpen(Block door) {
  Openable openable = (Openable) door.getBlockData();
  return openable.isOpen();
}

代码示例来源:origin: TheBusyBiscuit/Slimefun4

private static Block getAttachedBlock(Block block) {
  if (block.getBlockData() instanceof Directional) {
    return block.getRelative(((Directional) block.getBlockData()).getFacing().getOppositeFace());
  }
  return null;
}

代码示例来源:origin: catageek/ByteCart

@Override
public boolean read() {
  final BlockData md = this.getBlock().getBlockData();
  if(md instanceof Powerable) {
    return ((Powerable) md).isPowered();
  }
  return false;
}

代码示例来源:origin: TheBusyBiscuit/Slimefun4

private boolean isFullGrown(Block block){
  org.bukkit.block.data.Ageable ageable = ((org.bukkit.block.data.Ageable)block.getBlockData());
  return ageable.getAge() >= ageable.getMaximumAge();
}

代码示例来源:origin: catageek/ByteCart

@Override
  public boolean read() {
    if(((AnaloguePowerable) this.getBlock().getBlockData()).getPower() != 0) {
//            if(ByteCart.debug)
//                ByteCart.log.info("Redstone wire on at (" + this.getBlock().getLocation().toString() + ")");
      return true;
    }
//        if(ByteCart.debug)
//            ByteCart.log.info("Redstone wire off at (" + this.getBlock().getLocation().toString() + ")");

    return false;
  }

代码示例来源:origin: eccentricdevotion/TARDIS

private boolean isSiegeCube(Block b) {
  boolean faced = b.getType().equals(Material.BROWN_MUSHROOM_BLOCK);
  BlockData blockData = b.getBlockData();
  if (blockData instanceof MultipleFacing) {
    MultipleFacing mf = (MultipleFacing) b.getBlockData();
    for (BlockFace face : mf.getAllowedFaces()) {
      if (!mf.hasFace(face)) {
        return false;
      }
    }
  }
  return faced;
}

代码示例来源:origin: catageek/ByteCart

@Override
public boolean read() {
  BlockData md = this.getBlock().getBlockData();
  if(md instanceof Powerable) {
    return ((Powerable) md).isPowered();
  }
  return false;
}

代码示例来源:origin: eccentricdevotion/TARDIS

private boolean isDoorOpen(int id) {
    HashMap<String, Object> where = new HashMap<>();
    where.put("tardis_id", id);
    where.put("door_type", 1);
    ResultSetDoors rs = new ResultSetDoors(plugin, where, false);
    if (rs.resultSet()) {
      Openable door = (Openable) TARDISLocationGetters.getLocationFromDB(rs.getDoor_location(), 0.0f, 0.0f).getBlock().getBlockData();
      return door.isOpen();
    }
    return false;
  }
}

代码示例来源:origin: catageek/ByteCart

@Override
public boolean getBit(int index) {
  final AnaloguePowerable wire = ((AnaloguePowerable) this.getBlock().getBlockData());
  return (wire.getPower() & 1 << (length() - index)) != 0;
}

代码示例来源:origin: catageek/ByteCart

@Override
  public void run() {

    final Block block = component.getBlock();

    if (block.getBlockData() instanceof Switch) {
      final Switch button = (Switch) block.getBlockData();

      button.setPowered(false);
      block.setBlockData(button);

      MathUtil.forceUpdate(block.getRelative(button.getFacing().getOppositeFace()));
    }

    ActivatedButtonMap.remove(block.getLocation());
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

private void extend(Block b, Block l) {
  l.setBlockData(Material.PISTON_HEAD.createBlockData());
  Piston piston = (Piston) b.getBlockData();
  piston.setExtended(true);
  b.setBlockData(piston, true);
}

代码示例来源:origin: AddstarMC/Minigames

public void placeSigns() {
  List<Block> blocks = getSignBlocks(false);
  
  for (Block block : blocks) {
    block.setType(Material.WALL_SIGN);
    Directional d = (Directional) block.getBlockData();
    d.setFacing(facing);
    block.setBlockData(d);
  }
}

代码示例来源:origin: AddstarMC/Minigames

public MgBlockData(Block original, MinigamePlayer modifier){
  location = original.getLocation();
  state = original.getState();
  blockData = original.getBlockData().getAsString();
  if(modifier !=null)playerUUID = modifier.getUUID();
}

代码示例来源:origin: echurchill/CityWorld

@Override
public final void setBlock(int x, int y, int z, Material material, Type type) {
  Block block = getActualBlock(x, y, z);
  block.setType(material, false);
  BlockData data = block.getBlockData();
  try {
    if (data instanceof Slab)
      ((Slab) data).setType(type);
  } finally {
    block.setBlockData(data, getDoPhysics(x, z));
  }
}

代码示例来源:origin: AddstarMC/Minigames

@Override
  public String getAsString() {
    return String.format("%d,%d,%d,%s %s:%s", object.getX(), object.getY(), object.getZ(), object.getWorld().getName(), object.getType(), object.getBlockData().getAsString());
  }
};

代码示例来源:origin: echurchill/CityWorld

public final Block setBlock(int x, int y, int z, Material material, Half half) {
  Block block = getActualBlock(x, y, z);
  block.setType(material, false);
  BlockData data = block.getBlockData();
  try {
    if (data instanceof Bisected)
      ((Bisected) data).setHalf(half);
  } finally {
    block.setBlockData(data, getDoPhysics(x, z));
  }
  return block;
}

代码示例来源:origin: AddstarMC/Minigames

public CTFFlag(Location spawn, Team team, Player carrier, Minigame minigame){
  spawnLocation = spawn;
  data = spawnLocation.getBlock().getBlockData();
  spawnData = spawnLocation.getBlock().getState();
  signText = ((Sign)spawnLocation.getBlock().getState()).getLines();
  this.team = team;
  this.setMinigame(minigame);
  respawnTime = Minigames.getPlugin().getConfig().getInt("multiplayer.ctf.flagrespawntime");
}

相关文章