當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockState.getData方法代碼示例

本文整理匯總了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() + "]";
}
 
開發者ID:zachbr,項目名稱:Debuggery,代碼行數:9,代碼來源:OutputFormatter.java

示例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!");
	}

}
 
開發者ID:kadeska,項目名稱:MT_Core,代碼行數:39,代碼來源:GeneratorListener.java


注:本文中的org.bukkit.block.BlockState.getData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。