Search in sources :

Example 21 with PrepareItemCraftEvent

use of org.bukkit.event.inventory.PrepareItemCraftEvent in project WindSpigot by Wind-Development.

the class CraftEventFactory method callPreCraftEvent.

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);
}
Also used : CraftInventoryCrafting(org.bukkit.craftbukkit.inventory.CraftInventoryCrafting) PrepareItemCraftEvent(org.bukkit.event.inventory.PrepareItemCraftEvent)

Example 22 with PrepareItemCraftEvent

use of org.bukkit.event.inventory.PrepareItemCraftEvent in project PublicCrafters by BananaPuncher714.

the class CustomInventoryCrafting method setItems.

protected void setItems(List<org.bukkit.inventory.ItemStack> items) {
    int index = 0;
    for (org.bukkit.inventory.ItemStack item : items) {
        this.items.set(index++, CraftItemStack.asNMSCopy(item));
    }
    // Want to update the result without having to use a real player
    if (this.resultInventory instanceof InventoryCraftResult) {
        CustomContainerWorkbench container = new CustomContainerWorkbench(manager.mockPlayer.getBukkitEntity(), bloc, this, (InventoryCraftResult) resultInventory);
        container.a(this);
        CraftingInventory crafting = (CraftingInventory) container.getBukkitView().getTopInventory();
        Bukkit.getPluginManager().callEvent(new PrepareItemCraftEvent(crafting, container.getBukkitView(), false));
    }
    display.forceUpdate();
}
Also used : CraftingInventory(org.bukkit.inventory.CraftingInventory) PublicCraftingInventory(io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory) PrepareItemCraftEvent(org.bukkit.event.inventory.PrepareItemCraftEvent) InventoryCraftResult(net.minecraft.server.v1_13_R2.InventoryCraftResult)

Example 23 with PrepareItemCraftEvent

use of org.bukkit.event.inventory.PrepareItemCraftEvent in project PublicCrafters by BananaPuncher714.

the class CustomInventoryCrafting method setItems.

protected void setItems(List<org.bukkit.inventory.ItemStack> items) {
    int index = 0;
    for (org.bukkit.inventory.ItemStack item : items) {
        this.items.set(index++, CraftItemStack.asNMSCopy(item));
    }
    // Want to update the result without having to use a real player
    if (this.resultInventory instanceof InventoryCraftResult) {
        CustomContainerWorkbench container = new CustomContainerWorkbench(0, manager.mockPlayer.getBukkitEntity(), bloc, this, (InventoryCraftResult) resultInventory);
        container.a(this);
        CraftingInventory crafting = (CraftingInventory) container.getBukkitView().getTopInventory();
        Bukkit.getPluginManager().callEvent(new PrepareItemCraftEvent(crafting, container.getBukkitView(), false));
    }
    display.forceUpdate();
}
Also used : CraftingInventory(org.bukkit.inventory.CraftingInventory) PublicCraftingInventory(io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory) PrepareItemCraftEvent(org.bukkit.event.inventory.PrepareItemCraftEvent) InventoryCraftResult(net.minecraft.server.v1_14_R1.InventoryCraftResult)

Example 24 with PrepareItemCraftEvent

use of org.bukkit.event.inventory.PrepareItemCraftEvent in project PublicCrafters by BananaPuncher714.

the class CustomInventoryCrafting method setItems.

protected void setItems(List<org.bukkit.inventory.ItemStack> items) {
    int index = 0;
    for (org.bukkit.inventory.ItemStack item : items) {
        this.items.set(index++, CraftItemStack.asNMSCopy(item));
    }
    // Want to update the result without having to use a real player
    if (this.resultInventory instanceof InventoryCraftResult) {
        CustomContainerWorkbench container = new CustomContainerWorkbench(0, manager.mockPlayer.getBukkitEntity(), bloc, this, (InventoryCraftResult) resultInventory);
        container.a(this);
        CraftingInventory crafting = (CraftingInventory) container.getBukkitView().getTopInventory();
        Bukkit.getPluginManager().callEvent(new PrepareItemCraftEvent(crafting, container.getBukkitView(), false));
    }
    display.forceUpdate();
}
Also used : CraftingInventory(org.bukkit.inventory.CraftingInventory) PublicCraftingInventory(io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory) PrepareItemCraftEvent(org.bukkit.event.inventory.PrepareItemCraftEvent) InventoryCraftResult(net.minecraft.world.inventory.InventoryCraftResult)

Example 25 with PrepareItemCraftEvent

use of org.bukkit.event.inventory.PrepareItemCraftEvent in project PublicCrafters by BananaPuncher714.

the class CustomInventoryCrafting method setItems.

protected void setItems(List<org.bukkit.inventory.ItemStack> items) {
    int index = 0;
    for (org.bukkit.inventory.ItemStack item : items) {
        this.items.set(index++, CraftItemStack.asNMSCopy(item));
    }
    // Want to update the result without having to use a real player
    if (this.resultInventory instanceof InventoryCraftResult) {
        CustomContainerWorkbench container = new CustomContainerWorkbench(0, manager.mockPlayer.getBukkitEntity(), bloc, this, (InventoryCraftResult) resultInventory);
        container.a(this);
        CraftingInventory crafting = (CraftingInventory) container.getBukkitView().getTopInventory();
        Bukkit.getPluginManager().callEvent(new PrepareItemCraftEvent(crafting, container.getBukkitView(), false));
    }
    display.forceUpdate();
}
Also used : CraftingInventory(org.bukkit.inventory.CraftingInventory) PublicCraftingInventory(io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory) PrepareItemCraftEvent(org.bukkit.event.inventory.PrepareItemCraftEvent) InventoryCraftResult(net.minecraft.server.v1_15_R1.InventoryCraftResult)

Aggregations

PrepareItemCraftEvent (org.bukkit.event.inventory.PrepareItemCraftEvent)32 CraftingInventory (org.bukkit.inventory.CraftingInventory)20 PublicCraftingInventory (io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory)16 ItemStack (org.bukkit.inventory.ItemStack)6 Material (org.bukkit.Material)5 Player (org.bukkit.entity.Player)5 InventoryCraftResult (net.minecraft.world.inventory.InventoryCraftResult)4 EventHandler (org.bukkit.event.EventHandler)4 CustomItemStack (io.github.bakedlibs.dough.items.CustomItemStack)3 Bukkit (org.bukkit.Bukkit)3 EventPriority (org.bukkit.event.EventPriority)3 Test (org.junit.jupiter.api.Test)3 List (java.util.List)2 Map (java.util.Map)2 CommandSender (org.bukkit.command.CommandSender)2 CraftInventoryCrafting (org.bukkit.craftbukkit.inventory.CraftInventoryCrafting)2 CraftItemEvent (org.bukkit.event.inventory.CraftItemEvent)2 Recipe (org.bukkit.inventory.Recipe)2 RecipeManagerCraftEvent (haveric.recipeManager.api.events.RecipeManagerCraftEvent)1 RMCRecipeInfo (haveric.recipeManager.common.recipes.RMCRecipeInfo)1