本文整理汇总了Java中org.bukkit.Material.GLASS_BOTTLE属性的典型用法代码示例。如果您正苦于以下问题:Java Material.GLASS_BOTTLE属性的具体用法?Java Material.GLASS_BOTTLE怎么用?Java Material.GLASS_BOTTLE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.GLASS_BOTTLE属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSingleIngredientResult
/**
* Get the MaterialData that vanilla crafting recipes leave in a crafting inventory if the ingredient is of stack size 1.
* For most materials the returned data will have Material.AIR, but there are exceptions for filled buckets and dragons breath.
*
* @param ingredient the material data used as a crafting ingredient.
* @return the material data that vanilla recipes would give back upon crafting
*/
public static MaterialData getSingleIngredientResult(MaterialData ingredient) {
if (ingredient == null) return new MaterialData(Material.AIR);
switch(ingredient.getItemType()) {
case MILK_BUCKET:
case WATER_BUCKET:
case LAVA_BUCKET:
return new MaterialData(Material.BUCKET);
case DRAGONS_BREATH:
return new MaterialData(Material.GLASS_BOTTLE);
default: return new MaterialData(Material.AIR);
}
}
示例2: onItemConsume
@EventHandler
public void onItemConsume(PlayerItemConsumeEvent e){
Player p = e.getPlayer();
ItemStack item = e.getItem();
Material type = item != null ? item.getType() : Material.AIR;
int thirst = p.getLevel();
if (type == Material.POTION && item.getDurability() == 0 && p.getInventory().getItemInMainHand().isSimilar(item)){
p.getInventory().getItemInMainHand().setType(Material.AIR);
for (ItemStack i : p.getInventory().getContents()){
if (i.getType() == Material.GLASS_BOTTLE){
i.setType(Material.AIR);
}
}
p.setLevel(0);
if (thirst + 256 >= 1000){
p.setLevel(1000);
return;
}
p.setLevel(thirst + 256);
p.sendMessage(p.getLevel() + " // " + thirst + 256);
}
}
示例3: onPrepareCraft
@EventHandler
public void onPrepareCraft(PrepareItemCraftEvent e)
{
CraftingInventory inv = e.getInventory();
ItemStack result = inv.getResult();
if(result != null && result.getType() != Material.GLASS_BOTTLE)
{
List<ItemStack> bottles = Arrays.asList(inv.getMatrix());
Iterator<ItemStack> it = bottles.iterator();
while(it.hasNext())
{
ItemStack bottle = it.next();
if(bottle == null) continue;
if(bottle.getType().equals(Material.POTION))
{
if(!checkWaterBottle(bottle))
{
inv.setResult(null);
return;
}
}
}
}
}
示例4: onItemRefill
@EventHandler
public void onItemRefill(PlayerBucketFillEvent e){
if (e.getBucket() == Material.GLASS_BOTTLE || e.getBucket() == Material.POTION){
e.setItemStack(new AllItems().getPotion2());
}
}
示例5: 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);
}
}
}
}
}
}
}
示例6: clearJunk
public void clearJunk(){
World world = Bukkit.getWorld("kaospvp");
List<Entity> list = world.getEntities();
for(Entity e : list){
if(e instanceof Item){
Item it = (Item) e;
if( it.getItemStack().getType() == Material.POTION &&
it.getItemStack().getDurability() == 16453){
e.remove();
}
if( it.getItemStack().getType() == Material.GOLDEN_APPLE &&
it.getItemStack().getDurability() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.ARROW){
e.remove();
}
if( it.getItemStack().getType() == Material.GLASS_BOTTLE){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_BOOTS &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_LEGGINGS &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_CHESTPLATE &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_HELMET &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_SWORD &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.BOW &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.WOOD_AXE ||
it.getItemStack().getType() == Material.STONE_AXE ||
it.getItemStack().getType() == Material.GOLD_AXE ||
it.getItemStack().getType() == Material.IRON_AXE ||
it.getItemStack().getType() == Material.DIAMOND_AXE){
e.remove();
}
}
}
}
示例7: EnergyDrink
public EnergyDrink() {
super(2, "Energy Drink", Material.GLASS_BOTTLE, ChatColor.GREEN);
}