Search in sources :

Example 31 with InventoryCraftResult

use of net.minecraft.server.v1_8_R3.InventoryCraftResult 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[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_8_R3.InventoryCraftResult)

Example 32 with InventoryCraftResult

use of net.minecraft.server.v1_8_R3.InventoryCraftResult in project PublicCrafters by BananaPuncher714.

the class CustomTileEntityContainerWorkbench method createContainer.

/**
 * This is an ITileEntityContainer method that returns a new container for whatever tile entity
 */
@Override
public Container createContainer(PlayerInventory paramPlayerInventory, EntityHuman ent) {
    CustomInventoryCrafting crafting = manager.benches.get(bloc);
    if (crafting == null) {
        crafting = new CustomInventoryCrafting(bloc, manager, new SelfContainer(), 3, 3);
        manager.put(bloc, crafting);
    }
    IInventory result = crafting.resultInventory;
    if (result == null) {
        result = new InventoryCraftResult();
        crafting.resultInventory = result;
    }
    Container container = new CustomContainerWorkbench(ent.getBukkitEntity(), bloc, crafting, result);
    crafting.addContainer(container);
    return container;
}
Also used : IInventory(net.minecraft.server.v1_8_R3.IInventory) ITileEntityContainer(net.minecraft.server.v1_8_R3.ITileEntityContainer) Container(net.minecraft.server.v1_8_R3.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_8_R3.ContainerManager_v1_8_R3.SelfContainer) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_8_R3.ContainerManager_v1_8_R3.SelfContainer) InventoryCraftResult(net.minecraft.server.v1_8_R3.InventoryCraftResult)

Example 33 with InventoryCraftResult

use of net.minecraft.server.v1_8_R3.InventoryCraftResult 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[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_9_R2.InventoryCraftResult)

Example 34 with InventoryCraftResult

use of net.minecraft.server.v1_8_R3.InventoryCraftResult in project PublicCrafters by BananaPuncher714.

the class CustomTileEntityContainerWorkbench method createContainer.

/**
 * This is an ITileEntityContainer method that returns a new container for whatever tile entity
 */
@Override
public Container createContainer(PlayerInventory paramPlayerInventory, EntityHuman ent) {
    CustomInventoryCrafting crafting = manager.benches.get(bloc);
    if (crafting == null) {
        crafting = new CustomInventoryCrafting(bloc, manager, new SelfContainer(), 3, 3);
        manager.put(bloc, crafting);
    }
    IInventory result = crafting.resultInventory;
    if (result == null) {
        result = new InventoryCraftResult();
        crafting.resultInventory = result;
    }
    Container container = new CustomContainerWorkbench(ent.getBukkitEntity(), bloc, crafting, result);
    crafting.addContainer(container);
    return container;
}
Also used : IInventory(net.minecraft.server.v1_9_R2.IInventory) Container(net.minecraft.server.v1_9_R2.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_9_R2.ContainerManager_v1_9_R2.SelfContainer) ITileEntityContainer(net.minecraft.server.v1_9_R2.ITileEntityContainer) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_9_R2.ContainerManager_v1_9_R2.SelfContainer) InventoryCraftResult(net.minecraft.server.v1_9_R2.InventoryCraftResult)

Example 35 with InventoryCraftResult

use of net.minecraft.server.v1_8_R3.InventoryCraftResult 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[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_10_R1.InventoryCraftResult)

Aggregations

PublicCraftingInventory (io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory)12 PrepareItemCraftEvent (org.bukkit.event.inventory.PrepareItemCraftEvent)12 CraftingInventory (org.bukkit.inventory.CraftingInventory)12 InventoryCraftResult (net.minecraft.server.v1_11_R1.InventoryCraftResult)4 InventoryCraftResult (net.minecraft.server.v1_10_R1.InventoryCraftResult)3 InventoryCraftResult (net.minecraft.server.v1_12_R1.InventoryCraftResult)3 InventoryCraftResult (net.minecraft.server.v1_13_R1.InventoryCraftResult)3 InventoryCraftResult (net.minecraft.server.v1_13_R2.InventoryCraftResult)3 InventoryCraftResult (net.minecraft.server.v1_14_R1.InventoryCraftResult)3 InventoryCraftResult (net.minecraft.server.v1_15_R1.InventoryCraftResult)3 InventoryCraftResult (net.minecraft.server.v1_16_R1.InventoryCraftResult)3 InventoryCraftResult (net.minecraft.server.v1_16_R2.InventoryCraftResult)3 InventoryCraftResult (net.minecraft.server.v1_16_R3.InventoryCraftResult)3 InventoryCraftResult (net.minecraft.server.v1_8_R3.InventoryCraftResult)3 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_11_R1.ContainerManager_v1_11_R1.SelfContainer)2 Container (net.minecraft.server.v1_11_R1.Container)2 ITileEntityContainer (net.minecraft.server.v1_11_R1.ITileEntityContainer)2 InventoryCraftResult (net.minecraft.server.v1_9_R2.InventoryCraftResult)2 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_10_R1.ContainerManager_v1_10_R1.SelfContainer)1 SelfContainer (io.github.bananapuncher714.crafters.implementation.v1_12_R1.ContainerManager_v1_12_R1.SelfContainer)1