本文整理汇总了Java中org.bukkit.Material.CAULDRON属性的典型用法代码示例。如果您正苦于以下问题:Java Material.CAULDRON属性的具体用法?Java Material.CAULDRON怎么用?Java Material.CAULDRON使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.CAULDRON属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerInteract
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CAULDRON)
{
Optional<Well> optional = this.interactions.stream().filter(well -> normalize(well.getCauldronLocation()).equals(normalize(event.getClickedBlock().getLocation()))).findAny();
if (optional.isPresent())
optional.get().play(event.getPlayer());
}
}
示例2: onItemClick
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemClick(PlayerInteractEvent event)
{
if(event.isCancelled()) return;
if(event.hasItem())
{
Player player = event.getPlayer();
if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
{
ItemStack mainItem = player.getInventory().getItemInMainHand();
if(mainItem.getType() == Material.GLASS_BOTTLE)
{
if(event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
if(event.getClickedBlock().getType() == Material.CAULDRON && event.getClickedBlock().getData() != (byte)0)
{
Block fire = event.getClickedBlock().getRelative(BlockFace.DOWN);
event.setCancelled(true);
event.getClickedBlock().setData((byte)((int)event.getClickedBlock().getData() - 1));
ItemStack waterBottle = new ItemStack(Material.POTION, 1);
net.minecraft.server.v1_12_R1.ItemStack nmsStack_bottle = CraftItemStack.asNMSCopy(waterBottle);
NBTTagCompound compound_bottle = nmsStack_bottle.getTag();
compound_bottle.setString("Potion","minecraft:water");
compound_bottle.setInt("HideFlags", 32);
nmsStack_bottle.setTag(compound_bottle);
waterBottle = CraftItemStack.asBukkitCopy(nmsStack_bottle);
ItemMeta meta = waterBottle.getItemMeta();
if(fire != null && fire.getType() == Material.FIRE)
{
List<String> lore = Arrays.asList
(
ChatColor.RESET + "" + ChatColor.GRAY + Survival.Words.get("Purified")
);
meta.setLore(lore);
}
waterBottle.setItemMeta(meta);
if(mainItem.getAmount() > 1)
{
mainItem.setAmount(mainItem.getAmount() - 1);
if(player.getInventory().firstEmpty() != -1)
player.getInventory().addItem(waterBottle);
else
player.getWorld().dropItem(player.getLocation(), waterBottle);
}
else
{
player.getInventory().setItemInMainHand(waterBottle);
}
}
}
}
}
}
}