Search in sources :

Example 46 with ItemStack

use of net.minecraft.server.v1_15_R1.ItemStack in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method b.

/**
 * This might be for when the inventory closes?
 */
@Override
public void b(EntityHuman entity) {
    super.b(entity);
    // Make sure the craft inventory stops watching this container
    craftInventory.removeContainer(this);
    if (PublicCrafters.getInstance().isDropItem()) {
        if (!world.isClientSide) {
            for (int i = 0; i < 9; i++) {
                ItemStack itemstack = craftInventory.splitWithoutUpdate(i);
                if (itemstack != null) {
                    entity.drop(itemstack, false);
                }
            }
            setCraftResult();
            craftInventory.update();
        }
    }
}
Also used : ItemStack(net.minecraft.server.v1_11_R1.ItemStack)

Example 47 with ItemStack

use of net.minecraft.server.v1_15_R1.ItemStack in project PublicCrafters by BananaPuncher714.

the class CustomInventoryCrafting method splitStack.

@Override
public ItemStack splitStack(int i, int j) {
    ItemStack itemstack = ContainerUtil.a(items, i, j);
    if (!itemstack.isEmpty()) {
        for (Container container : containers) {
            container.a(this);
        }
    }
    // Update the armorstand grid
    display.update();
    return itemstack;
}
Also used : SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_11_R1.ContainerManager_v1_11_R1.SelfContainer) Container(net.minecraft.server.v1_11_R1.Container) CraftItemStack(org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_11_R1.ItemStack)

Example 48 with ItemStack

use of net.minecraft.server.v1_15_R1.ItemStack in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method shiftClick.

// Overrides 1.12.2
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
    ItemStack itemstack = ItemStack.a;
    Slot slot = (Slot) theseSlots.get(i);
    if ((slot != null) && (slot.hasItem())) {
        ItemStack itemstack1 = slot.getItem();
        itemstack = itemstack1.cloneItemStack();
        if (i == 0) {
            itemstack1.getItem().b(itemstack1, world, entityhuman);
            if (!a(itemstack1, 10, 46, true)) {
                return ItemStack.a;
            }
            slot.a(itemstack1, itemstack);
        } else if ((i >= 10) && (i < 37)) {
            if (!a(itemstack1, 37, 46, false)) {
                return ItemStack.a;
            }
        } else if ((i >= 37) && (i < 46)) {
            if (!a(itemstack1, 10, 37, false)) {
                return ItemStack.a;
            }
        } else if (!a(itemstack1, 10, 46, false)) {
            return ItemStack.a;
        }
        if (itemstack1.isEmpty()) {
            slot.set(ItemStack.a);
        } else {
            slot.f();
        }
        if (itemstack1.getCount() == itemstack.getCount()) {
            return ItemStack.a;
        }
        ItemStack itemstack2 = slot.a(entityhuman, itemstack1);
        if (i == 0) {
            entityhuman.drop(itemstack2, false);
        }
    }
    return itemstack;
}
Also used : Slot(net.minecraft.server.v1_12_R1.Slot) PacketPlayOutSetSlot(net.minecraft.server.v1_12_R1.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 49 with ItemStack

use of net.minecraft.server.v1_15_R1.ItemStack in project PublicCrafters by BananaPuncher714.

the class CustomContainerWorkbench method setCraftResult.

public void setCraftResult() {
    if (!world.isClientSide) {
        EntityPlayer entityplayer = (EntityPlayer) ((CraftHumanEntity) viewer).getHandle();
        ItemStack itemstack = ItemStack.a;
        IRecipe irecipe = CraftingManager.b(craftInventory, world);
        if ((irecipe != null) && ((irecipe.c()) || (!world.getGameRules().getBoolean("doLimitedCrafting")) || (entityplayer.F().b(irecipe)))) {
            resultInventory.a(irecipe);
            itemstack = irecipe.craftItem(craftInventory);
        }
        itemstack = CraftEventFactory.callPreCraftEvent(craftInventory, itemstack, getBukkitView(), false);
        resultInventory.setItem(0, itemstack);
        entityplayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, itemstack));
        for (Object listener : listeners) {
            EntityPlayer player = (EntityPlayer) listener;
            player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, 0, itemstack));
        }
    }
}
Also used : IRecipe(net.minecraft.server.v1_12_R1.IRecipe) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) PacketPlayOutSetSlot(net.minecraft.server.v1_12_R1.PacketPlayOutSetSlot) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Example 50 with ItemStack

use of net.minecraft.server.v1_15_R1.ItemStack in project PublicCrafters by BananaPuncher714.

the class CustomInventoryCrafting method splitStack.

@Override
public ItemStack splitStack(int i, int j) {
    ItemStack itemstack = ContainerUtil.a(items, i, j);
    if (!itemstack.isEmpty()) {
        for (Container container : containers) {
            container.a(this);
        }
    }
    // Update the armorstand grid
    display.update();
    return itemstack;
}
Also used : SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_12_R1.ContainerManager_v1_12_R1.SelfContainer) Container(net.minecraft.server.v1_12_R1.Container) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_12_R1.ItemStack)

Aggregations

ItemStack (net.minecraft.server.v1_8_R3.ItemStack)26 ItemStack (net.minecraft.server.v1_12_R1.ItemStack)24 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)20 ItemStack (net.minecraft.server.v1_16_R3.ItemStack)19 IconMenuItem (de.Keyle.MyPet.api.gui.IconMenuItem)18 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)17 CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)16 ItemStack (net.minecraft.server.v1_11_R1.ItemStack)13 ItemStack (net.minecraft.server.v1_7_R4.ItemStack)12 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)11 CraftItemStack (org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack)11 ItemStack (net.minecraft.server.v1_10_R1.ItemStack)10 NBTTagCompound (net.minecraft.server.v1_8_R3.NBTTagCompound)10 TagCompound (de.keyle.knbt.TagCompound)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)9 Field (java.lang.reflect.Field)8 ItemStack (net.minecraft.server.v1_13_R2.ItemStack)8 ItemStack (net.minecraft.server.v1_15_R1.ItemStack)8 NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)8