类org.bukkit.inventory.BrewerInventory源码实例Demo

下面列出了怎么用org.bukkit.inventory.BrewerInventory的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: askyblock   文件: AcidInventory.java
/**
 * This event makes sure that any acid bottles become potions without the
 * warning
 * 
 * @param e - event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBrewComplete(final BrewEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());

    if (e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
        //if (Settings.acidBottle && Settings.acidDamage>0 && e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) {

        plugin.getLogger().info("DEBUG: Brew Event called");
        BrewerInventory inv = e.getContents();
        int i = 0;
        for (ItemStack item : inv.getContents()) {
            if (item != null) {
                // Remove lore
                ItemMeta meta = item.getItemMeta();
                plugin.getLogger().info("DEBUG: " + meta.getDisplayName());
                meta.setDisplayName(null);
                inv.setItem(i, item);
            }
            i++;
        }
    }
}
 
源代码2 项目: Kettle   文件: CraftBrewingStand.java
@Override
public BrewerInventory getInventory() {
    if (!this.isPlaced()) {
        return this.getSnapshotInventory();
    }

    return new CraftInventoryBrewer(this.getTileEntity());
}
 
源代码3 项目: Slimefun4   文件: CargoUtils.java
static ItemStack withdrawFromVanillaInventory(Block node, ItemStack template, Inventory inv) {
    ItemStack[] contents = inv.getContents();
    int minSlot = 0;
    int maxSlot = contents.length;

    if (inv instanceof FurnaceInventory) {
        minSlot = 2;
        maxSlot = 3;
    }
    else if (inv instanceof BrewerInventory) {
        maxSlot = 3;
    }

    ItemStackWrapper wrapper = new ItemStackWrapper(template);

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

        if (SlimefunUtils.isItemSimilar(itemInSlot, wrapper, true) && matchesFilter(node, itemInSlot)) {
            if (itemInSlot.getAmount() > template.getAmount()) {
                itemInSlot.setAmount(itemInSlot.getAmount() - template.getAmount());
                return template;
            }
            else {
                ItemStack clone = itemInSlot.clone();
                itemInSlot.setAmount(0);
                return clone;
            }
        }
    }

    return null;
}
 
源代码4 项目: CraftserveRadiation   文件: LugolsIodinePotion.java
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBrew(BrewEvent event) {
    if (!config.recipe.enabled) {
        return;
    }

    BrewerInventory inventory = event.getContents();
    BrewingStandWindow window = BrewingStandWindow.fromArray(inventory.getContents());

    if (!window.ingredient.getType().equals(config.recipe.ingredient)) {
        return;
    }

    boolean[] modified = new boolean[BrewingStandWindow.SLOTS];

    for (int i = 0; i < BrewingStandWindow.SLOTS; i++) {
        ItemStack result = window.results[i];
        if (result == null) {
            continue; // nothing in this slot
        }

        ItemMeta itemMeta = result.getItemMeta();
        if (!(itemMeta instanceof PotionMeta)) {
            continue;
        }

        PotionMeta potionMeta = (PotionMeta) itemMeta;
        if (potionMeta.getBasePotionData().getType().equals(config.recipe.basePotion)) {
            result.setItemMeta(this.convert(potionMeta));

            modified[i] = true;
        }
    }

    // delay this, because nms changes item stacks after BrewEvent is called
    this.plugin.getServer().getScheduler().runTask(this.plugin, () -> {
        for (int i = 0; i < BrewingStandWindow.SLOTS; i++) {
            if (modified[i]) {
                ItemStack[] contents = inventory.getContents();
                contents[i] = window.getResult(i);
                inventory.setContents(contents);
            }
        }
    });
}
 
源代码5 项目: Kettle   文件: BrewingStand.java
@Override
BrewerInventory getInventory();
 
源代码6 项目: Kettle   文件: BrewingStand.java
@Override
BrewerInventory getSnapshotInventory();
 
源代码7 项目: Kettle   文件: BrewEvent.java
public BrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) {
    super(brewer);
    this.contents = contents;
    this.fuelLevel = fuelLevel;
}
 
源代码8 项目: Kettle   文件: CraftBrewingStand.java
@Override
public BrewerInventory getSnapshotInventory() {
    return new CraftInventoryBrewer(this.getSnapshot());
}
 
源代码9 项目: Thermos   文件: CraftBrewingStand.java
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
 
源代码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 项目: Kettle   文件: BrewEvent.java
/**
 * Gets the contents of the Brewing Stand.
 *
 * @return the contents
 */
public BrewerInventory getContents() {
    return contents;
}
 
 类所在包
 同包方法