public InventoryType getType() { // Thanks to Droppers extending Dispensers, order is important. if (inventory instanceof InventoryCrafting) { return inventory.getSize() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING; } else if (inventory instanceof PlayerInventory) { return InventoryType.PLAYER; } else if (inventory instanceof TileEntityDropper) { return InventoryType.DROPPER; } else if (inventory instanceof TileEntityDispenser) { return InventoryType.DISPENSER; } else if (inventory instanceof TileEntityFurnace) { return InventoryType.FURNACE; } else if (inventory instanceof ContainerEnchantTableInventory) { return InventoryType.ENCHANTING; } else if (inventory instanceof TileEntityBrewingStand) { return InventoryType.BREWING; } else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) { return ((CraftInventoryCustom.MinecraftInventory) inventory).getType(); } else if (inventory instanceof InventoryEnderChest) { return InventoryType.ENDER_CHEST; } else if (inventory instanceof InventoryMerchant) { return InventoryType.MERCHANT; } else if (inventory instanceof TileEntityBeacon) { return InventoryType.BEACON; } else if (inventory instanceof ContainerAnvilInventory) { return InventoryType.ANVIL; } else if (inventory instanceof IHopper) { return InventoryType.HOPPER; } else { return InventoryType.CHEST; } }
public static ItemStack callPreCraftEvent(InventoryCrafting matrix, ItemStack result, InventoryView lastCraftView, boolean isRepair) { CraftInventoryCrafting inventory = new CraftInventoryCrafting(matrix, matrix.resultInventory); inventory.setResult(CraftItemStack.asCraftMirror(result)); PrepareItemCraftEvent event = new PrepareItemCraftEvent(inventory, lastCraftView, isRepair); Bukkit.getPluginManager().callEvent(event); org.bukkit.inventory.ItemStack bitem = event.getInventory().getResult(); return CraftItemStack.asNMSCopy(bitem); }
public InventoryType getType() { // Thanks to Droppers extending Dispensers, order is important. if (inventory instanceof InventoryCrafting) { return inventory.getSize() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING; } else if (inventory instanceof PlayerInventory) { return InventoryType.PLAYER; } else if (inventory instanceof TileEntityDropper) { return InventoryType.DROPPER; } else if (inventory instanceof TileEntityDispenser) { return InventoryType.DISPENSER; } else if (inventory instanceof TileEntityFurnace) { return InventoryType.FURNACE; } else if (this instanceof CraftInventoryEnchanting) { return InventoryType.ENCHANTING; } else if (inventory instanceof TileEntityBrewingStand) { return InventoryType.BREWING; } else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) { return ((CraftInventoryCustom.MinecraftInventory) inventory).getType(); } else if (inventory instanceof InventoryEnderChest) { return InventoryType.ENDER_CHEST; } else if (inventory instanceof InventoryMerchant) { return InventoryType.MERCHANT; } else if (inventory instanceof TileEntityBeacon) { return InventoryType.BEACON; } else if (this instanceof CraftInventoryAnvil) { return InventoryType.ANVIL; } else if (inventory instanceof IHopper) { return InventoryType.HOPPER; } else { return InventoryType.CHEST; } }
public CraftInventoryCrafting(InventoryCrafting inventory, IInventory resultInventory) { super(inventory); this.resultInventory = resultInventory; }
public Recipe getRecipe() { IRecipe recipe = ((InventoryCrafting)getInventory()).currentRecipe; return recipe == null ? null : recipe.toBukkitRecipe(); }