org.bukkit.Material#SPLASH_POTION源码实例Demo

下面列出了org.bukkit.Material#SPLASH_POTION 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Transport-Pipes   文件: BrewingStandContainer.java
@Override
public int spaceForItem(TPDirection insertDirection, ItemStack insertion) {
    if (isInvLocked(cachedBrewingStand)) {
        return 0;
    }
    if (insertion.getType() == Material.POTION || insertion.getType() == Material.SPLASH_POTION || insertion.getType() == Material.LINGERING_POTION) {
        if (cachedInv.getItem(0) != null && cachedInv.getItem(1) != null && cachedInv.getItem(2) != null) {
            return 0;
        } else {
            return 1;
        }
    } else if (insertDirection.isSide() && insertion.getType() == Material.BLAZE_POWDER) {
        return spaceForItem(cachedInv.getFuel(), insertion);
    } else if (isBrewingIngredient(insertion.getType())) {
        return spaceForItem(cachedInv.getIngredient(), insertion);
    } else {
        return 0;
    }
}
 
源代码2 项目: Slimefun4   文件: AutoDrier.java
private ItemStack getOutput(ItemStack item) {
    for (int i = 0; i < recipeList.size(); i += 2) {
        if (SlimefunUtils.isItemSimilar(item, recipeList.get(i), true)) {
            return recipeList.get(i + 1);
        }
    }

    if (Tag.SAPLINGS.isTagged(item.getType())) {
        return new ItemStack(Material.STICK, 2);
    }
    else if (Tag.LEAVES.isTagged(item.getType())) {
        return new ItemStack(Material.STICK, 1);
    }
    else if (item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION) {
        return new ItemStack(Material.GLASS_BOTTLE);
    }

    return null;
}
 
源代码3 项目: Kettle   文件: Potion.java
/**
 * Converts this potion to an {@link ItemStack} with the specified amount
 * and a correct damage value.
 *
 * @param amount The amount of the ItemStack
 * @return The created ItemStack
 */
public ItemStack toItemStack(int amount) {
    Material material;
    if (isSplash()) {
        material = Material.SPLASH_POTION;
    } else {
        material = Material.POTION;
    }
    ItemStack itemStack = new ItemStack(material, amount);
    PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
    meta.setBasePotionData(new PotionData(type, level == 2, extended));
    itemStack.setItemMeta(meta);
    return itemStack;
}
 
源代码4 项目: Transport-Pipes   文件: BrewingStandContainer.java
@Override
public ItemStack insertItem(TPDirection insertDirection, ItemStack insertion) {
    if (!isInLoadedChunk()) {
        return insertion;
    }
    if (isInvLocked(cachedBrewingStand)) {
        return insertion;
    }
    if (insertion.getType() == Material.POTION || insertion.getType() == Material.SPLASH_POTION || insertion.getType() == Material.LINGERING_POTION) {
        if (cachedInv.getItem(0) == null) {
            cachedInv.setItem(0, insertion);
            return null;
        } else if (cachedInv.getItem(1) == null) {
            cachedInv.setItem(1, insertion);
            return null;
        } else if (cachedInv.getItem(2) == null) {
            cachedInv.setItem(2, insertion);
            return null;
        }
    } else if (insertDirection.isSide() && insertion.getType() == Material.BLAZE_POWDER) {
        ItemStack oldFuel = cachedInv.getFuel();
        cachedInv.setFuel(accumulateItems(oldFuel, insertion));
        if (insertion == null || insertion.getAmount() == 0) {
            insertion = null;
        }
    } else if (isBrewingIngredient(insertion.getType())) {
        ItemStack oldIngredient = cachedInv.getIngredient();
        cachedInv.setIngredient(accumulateItems(oldIngredient, insertion));
        if (insertion == null || insertion.getAmount() == 0) {
            insertion = null;
        }
    }
    return insertion;
}
 
源代码5 项目: AACAdditionPro   文件: AutoPotion.java
@EventHandler
public void onInteract(final PlayerInteractEvent event)
{
    final User user = UserManager.getUser(event.getPlayer().getUniqueId());

    // Not bypassed
    if (User.isUserInvalid(user, this.getModuleType())) {
        return;
    }

    // Timeout
    if (user.getTimestampMap().recentlyUpdated(TimestampKey.AUTOPOTION_TIMEOUT, timeout)) {
        event.setCancelled(true);
        return;
    }

    // Is the action a right-click that can throw a potion
    if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) &&
        // The item is a throwable potion
        event.getItem() != null &&
        event.getMaterial() == Material.SPLASH_POTION &&
        // The last sudden movement was not long ago
        user.getTimestampMap().recentlyUpdated(TimestampKey.AUTOPOTION_DETECTION, timeOffset))
    {
        user.getDataMap().setValue(DataKey.AUTOPOTION_ALREADY_THROWN, true);
        // Here the timestamp is used to contain the data of the last splash
        user.getTimestampMap().updateTimeStamp(TimestampKey.AUTOPOTION_DETECTION);
    }
}
 
源代码6 项目: NBTEditor   文件: PotionVariable.java
@Override
public void setItem(ItemStack item) {
	if (item != null) {
		Material type = item.getType();
		if (type != Material.SPLASH_POTION && type != Material.LINGERING_POTION) {
			item.setType(Material.SPLASH_POTION);
		}
	}
	super.setItem(item);
}
 
源代码7 项目: NBTEditor   文件: PotionVariable.java
@Override
public boolean isValidItem(Player player, ItemStack item) {
	Material type = item.getType();
	if (type != Material.POTION && type != Material.SPLASH_POTION && type != Material.LINGERING_POTION) {
		player.sendMessage("§cThat must be a must be a potion!");
		return false;
	}
	return true;
}
 
源代码8 项目: ProjectAres   文件: GlobalItemParser.java
public ItemStack parseItem(Element el, Material type, short damage) throws InvalidXMLException {
    int amount = XMLUtils.parseNumber(el.getAttribute("amount"), Integer.class, 1);

    // If the item is a potion with non-zero damage, and there is
    // no modern potion ID, decode the legacy damage value.
    final Potion legacyPotion;
    if(type == Material.POTION && damage > 0 && el.getAttribute("potion") == null) {
        try {
            legacyPotion = Potion.fromDamage(damage);
        } catch(IllegalArgumentException e) {
            throw new InvalidXMLException("Invalid legacy potion damage value " + damage + ": " + e.getMessage(), el, e);
        }

        // If the legacy splash bit is set, convert to a splash potion
        if(legacyPotion.isSplash()) {
            type = Material.SPLASH_POTION;
            legacyPotion.setSplash(false);
        }

        // Potions always have damage 0
        damage = 0;
    } else {
        legacyPotion = null;
    }

    ItemStack itemStack = new ItemStack(type, amount, damage);
    if(itemStack.getType() != type) {
        throw new InvalidXMLException("Invalid item/block", el);
    }

    final ItemMeta meta = itemStack.getItemMeta();
    if(meta != null) { // This happens if the item is "air"
        parseItemMeta(el, meta);

        // If we decoded a legacy potion, apply it now, but only if there are no custom effects.
        // This emulates the old behavior of custom effects overriding default effects.
        if(legacyPotion != null) {
            final PotionMeta potionMeta = (PotionMeta) meta;
            if(!potionMeta.hasCustomEffects()) {
                potionMeta.setBasePotionData(new PotionData(legacyPotion.getType(),
                                                            legacyPotion.hasExtendedDuration(),
                                                            legacyPotion.getLevel() == 2));
            }
        }

        itemStack.setItemMeta(meta);
    }

    return itemStack;
}
 
源代码9 项目: Slimefun4   文件: AutoBrewer.java
private ItemStack brew(Material input, Material potionType, PotionMeta potion) {
    PotionData data = potion.getBasePotionData();

    if (data.getType() == PotionType.WATER) {
        if (input == Material.FERMENTED_SPIDER_EYE) {
            potion.setBasePotionData(new PotionData(PotionType.WEAKNESS, false, false));
            return new ItemStack(potionType);
        }
        else if (input == Material.NETHER_WART) {
            potion.setBasePotionData(new PotionData(PotionType.AWKWARD, false, false));
            return new ItemStack(potionType);
        }
        else if (potionType == Material.POTION && input == Material.GUNPOWDER) {
            return new ItemStack(Material.SPLASH_POTION);
        }
        else if (potionType == Material.SPLASH_POTION && input == Material.DRAGON_BREATH) {
            return new ItemStack(Material.LINGERING_POTION);
        }
        else {
            return null;
        }

    }
    else if (input == Material.FERMENTED_SPIDER_EYE) {
        potion.setBasePotionData(new PotionData(fermentations.get(data.getType()), false, false));
        return new ItemStack(potionType);
    }
    else if (input == Material.REDSTONE) {
        potion.setBasePotionData(new PotionData(data.getType(), true, data.isUpgraded()));
        return new ItemStack(potionType);
    }
    else if (input == Material.GLOWSTONE_DUST) {
        potion.setBasePotionData(new PotionData(data.getType(), data.isExtended(), true));
        return new ItemStack(potionType);
    }
    else if (data.getType() == PotionType.AWKWARD && potionRecipes.containsKey(input)) {
        potion.setBasePotionData(new PotionData(potionRecipes.get(input), false, false));
        return new ItemStack(potionType);
    }
    else {
        return null;
    }
}
 
源代码10 项目: Slimefun4   文件: CargoUtils.java
static ItemStack insertIntoVanillaInventory(ItemStack stack, Inventory inv) {
    ItemStack[] contents = inv.getContents();
    int minSlot = 0;
    int maxSlot = contents.length;

    // Check if it is a normal furnace
    if (inv instanceof FurnaceInventory) {
        // Check if it is fuel or not
        if (stack.getType().isFuel()) {
            maxSlot = 2;

            // Any non-smeltable items should not land in the upper slot
            if (!isSmeltable(stack, true)) {
                minSlot = 1;
            }
        }
        else {
            maxSlot = 1;
        }
    }
    else if (inv instanceof BrewerInventory) {
        if (stack.getType() == Material.POTION || stack.getType() == Material.LINGERING_POTION || stack.getType() == Material.SPLASH_POTION) {
            // Potions slot
            maxSlot = 3;
        }
        else if (stack.getType() == Material.BLAZE_POWDER) {
            // Blaze Powder slot
            minSlot = 4;
            maxSlot = 5;
        }
        else {
            // Input slot
            minSlot = 3;
            maxSlot = 4;
        }
    }

    ItemStackWrapper wrapper = new ItemStackWrapper(stack);

    for (int slot = minSlot; slot < maxSlot; slot++) {
        // Changes to this ItemStack are synchronized with the Item in the Inventory
        ItemStack itemInSlot = contents[slot];

        if (itemInSlot == null) {
            inv.setItem(slot, stack);
            return null;
        }
        else {
            int maxStackSize = itemInSlot.getType().getMaxStackSize();

            if (SlimefunUtils.isItemSimilar(itemInSlot, wrapper, true, false) && itemInSlot.getAmount() < maxStackSize) {
                int amount = itemInSlot.getAmount() + stack.getAmount();

                if (amount > maxStackSize) {
                    stack.setAmount(amount - maxStackSize);
                }
                else {
                    stack = null;
                }

                itemInSlot.setAmount(Math.min(amount, maxStackSize));
                // Setting item in inventory will clone the ItemStack
                inv.setItem(slot, itemInSlot);

                return stack;
            }
        }
    }

    return stack;
}
 
源代码11 项目: Slimefun4   文件: AutoBrewer.java
/**
 * Checks whether a given {@link Material} is a valid Potion material.
 * 
 * @param mat
 *            The {@link Material} to check
 * 
 * @return Whether this {@link Material} is a valid potion
 */
private boolean isPotion(Material mat) {
    return mat == Material.POTION || mat == Material.SPLASH_POTION || mat == Material.LINGERING_POTION;
}
 
 方法所在类
 同类方法