org.bukkit.inventory.BrewerInventory Java Examples
The following examples show how to use
org.bukkit.inventory.BrewerInventory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AcidInventory.java From askyblock with GNU General Public License v2.0 | 6 votes |
/** * 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++; } } }
Example #2
Source File: CraftBrewingStand.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public BrewerInventory getInventory() { if (!this.isPlaced()) { return this.getSnapshotInventory(); } return new CraftInventoryBrewer(this.getTileEntity()); }
Example #3
Source File: CargoUtils.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
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; }
Example #4
Source File: LugolsIodinePotion.java From CraftserveRadiation with Apache License 2.0 | 4 votes |
@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); } } }); }
Example #5
Source File: BrewingStand.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override BrewerInventory getInventory();
Example #6
Source File: BrewingStand.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override BrewerInventory getSnapshotInventory();
Example #7
Source File: BrewEvent.java From Kettle with GNU General Public License v3.0 | 4 votes |
public BrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) { super(brewer); this.contents = contents; this.fuelLevel = fuelLevel; }
Example #8
Source File: CraftBrewingStand.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public BrewerInventory getSnapshotInventory() { return new CraftInventoryBrewer(this.getSnapshot()); }
Example #9
Source File: CraftBrewingStand.java From Thermos with GNU General Public License v3.0 | 4 votes |
public BrewerInventory getInventory() { return new CraftInventoryBrewer(brewingStand); }
Example #10
Source File: CargoUtils.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
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; }
Example #11
Source File: BrewEvent.java From Kettle with GNU General Public License v3.0 | 2 votes |
/** * Gets the contents of the Brewing Stand. * * @return the contents */ public BrewerInventory getContents() { return contents; }