本文整理匯總了Java中org.bukkit.block.BlockState.getData方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockState.getData方法的具體用法?Java BlockState.getData怎麽用?Java BlockState.getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.block.BlockState
的用法示例。
在下文中一共展示了BlockState.getData方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleBlockState
import org.bukkit.block.BlockState; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Nonnull
private static String handleBlockState(BlockState blockState) {
return "[" + blockState.getData() + ", " +
"id=" + blockState.getTypeId() + ", " +
"light=" + blockState.getLightLevel() + ", " +
blockState.getLocation() + "]";
}
示例2: onLeverOrButton
import org.bukkit.block.BlockState; //導入方法依賴的package包/類
@EventHandler
public void onLeverOrButton(PlayerInteractEvent event) {
Block clickedBlock = event.getClickedBlock();
Player player = event.getPlayer();
if (clickedBlock == null)
return;
String chunk = clickedBlock.getLocation().getChunk().getX() + ";"
+ clickedBlock.getLocation().getChunk().getZ();
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (!powerable.containsKey(clickedBlock.getWorld().getName()))
return;
if (powerable.get(clickedBlock.getWorld().getName()).getList(chunk).contains(clickedBlock.getLocation()))
return;
// We cancel; send smoke particles for button, and we just turn off the
// lever (if it was, for some reason, on).
if (clickedBlock.getType() == Material.STONE_BUTTON || clickedBlock.getType() == Material.WOOD_BUTTON) {
clickedBlock.getWorld().spawnParticle(Particle.SMOKE_NORMAL, clickedBlock.getLocation().add(0.5, 1, 0.5), 7,
0, 0.2, 0, 0.03);
player.sendMessage(MortuusTerraCore.NOTI_PREFIX + ChatColor.RED + " There is no generator in range!");
} else if (clickedBlock.getType() == Material.LEVER) {
BlockState state = clickedBlock.getState();
Lever lever = (Lever) state.getData();
lever.setPowered(false);
state.setData(lever);
state.update();
clickedBlock.getWorld().spawnParticle(Particle.SMOKE_NORMAL, clickedBlock.getLocation().add(0.5, 1, 0.5), 7,
0, 0.2, 0, 0.03);
player.sendMessage(MortuusTerraCore.NOTI_PREFIX + ChatColor.RED + " There is no generator in range!");
}
}