當前位置: 首頁>>代碼示例>>Java>>正文


Java InventoryMoveItemEvent.isCancelled方法代碼示例

本文整理匯總了Java中org.bukkit.event.inventory.InventoryMoveItemEvent.isCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java InventoryMoveItemEvent.isCancelled方法的具體用法?Java InventoryMoveItemEvent.isCancelled怎麽用?Java InventoryMoveItemEvent.isCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.inventory.InventoryMoveItemEvent的用法示例。


在下文中一共展示了InventoryMoveItemEvent.isCancelled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dispense

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
public void dispense(World world, int i, int j, int k) { // CraftBukkit - protected -> public
    SourceBlock sourceblock = new SourceBlock(world, i, j, k);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) sourceblock.getTileEntity();

    if (tileentitydispenser != null) {
        int l = tileentitydispenser.i();

        if (l < 0) {
            world.triggerEffect(1001, i, j, k, 0);
        } else {
            ItemStack itemstack = tileentitydispenser.getItem(l);
            int i1 = world.getData(i, j, k) & 7;
            IInventory iinventory = TileEntityHopper.getInventoryAt(world, (double) (i + Facing.b[i1]), (double) (j + Facing.c[i1]), (double) (k + Facing.d[i1]));
            ItemStack itemstack1;

            if (iinventory != null) {
                // CraftBukkit start - Fire event when pushing items into other inventories
                CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().a(1));

                org.bukkit.inventory.Inventory destinationInventory;
                // Have to special case large chests as they work oddly
                if (iinventory instanceof InventoryLargeChest) {
                    destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
                } else {
                    destinationInventory = iinventory.getOwner().getInventory();
                }

                InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                world.getServer().getPluginManager().callEvent(event);
                if (event.isCancelled()) {
                    return;
                }
                itemstack1 = TileEntityHopper.addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.OPPOSITE_FACING[i1]);
                if (event.getItem().equals(oitemstack) && itemstack1 == null) {
                    // CraftBukkit end
                    itemstack1 = itemstack.cloneItemStack();
                    if (--itemstack1.count == 0) {
                        itemstack1 = null;
                    }
                } else {
                    itemstack1 = itemstack.cloneItemStack();
                }
            } else {
                itemstack1 = this.P.a(sourceblock, itemstack);
                if (itemstack1 != null && itemstack1.count == 0) {
                    itemstack1 = null;
                }
            }

            tileentitydispenser.setItem(l, itemstack1);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:CraftBukkit,代碼行數:54,代碼來源:BlockDropper.java

示例2: y

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
private boolean y() {
    IInventory iinventory = this.z();

    if (iinventory == null) {
        return false;
    } else {
        int i = Facing.OPPOSITE_FACING[BlockHopper.b(this.p())];

        if (this.a(iinventory, i)) {
            return false;
        } else {
            for (int j = 0; j < this.getSize(); ++j) {
                if (this.getItem(j) != null) {
                    ItemStack itemstack = this.getItem(j).cloneItemStack();
                    // CraftBukkit start - Call event when pushing items into other inventories
                    CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(j, 1));

                    Inventory destinationInventory;
                    // Have to special case large chests as they work oddly
                    if (iinventory instanceof InventoryLargeChest) {
                        destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
                    } else {
                        destinationInventory = iinventory.getOwner().getInventory();
                    }

                    InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                    this.getWorld().getServer().getPluginManager().callEvent(event);
                    if (event.isCancelled()) {
                        this.setItem(j, itemstack);
                        this.c(8); // Delay hopper checks
                        return false;
                    }
                    ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), i);

                    if (itemstack1 == null || itemstack1.count == 0) {
                        if (event.getItem().equals(oitemstack)) {
                            iinventory.update();
                        } else {
                            this.setItem(j, itemstack);
                        }
                        // CraftBukkit end
                        return true;
                    }

                    this.setItem(j, itemstack);
                }
            }

            return false;
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:CraftBukkit,代碼行數:53,代碼來源:TileEntityHopper.java

示例3: tryTakeInItemFromSlot

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
private static boolean tryTakeInItemFromSlot(IHopper ihopper, IInventory iinventory, int i, int j) {
    ItemStack itemstack = iinventory.getItem(i);

    if (itemstack != null && canTakeItemFromInventory(iinventory, itemstack, i, j)) {
        ItemStack itemstack1 = itemstack.cloneItemStack();
        // CraftBukkit start - Call event on collection of items from inventories into the hopper
        CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1));

        Inventory sourceInventory;
        // Have to special case large chests as they work oddly
        if (iinventory instanceof InventoryLargeChest) {
            sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
        } else {
            sourceInventory = iinventory.getOwner().getInventory();
        }

        InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);

        ihopper.getWorld().getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            iinventory.setItem(i, itemstack1);

            if (ihopper instanceof TileEntityHopper) {
                ((TileEntityHopper) ihopper).c(8); // Delay hopper checks
            } else if (ihopper instanceof EntityMinecartHopper) {
                ((EntityMinecartHopper) ihopper).l(4); // Delay hopper minecart checks
            }

            return false;
        }
        ItemStack itemstack2 = addItem(ihopper, CraftItemStack.asNMSCopy(event.getItem()), -1);

        if (itemstack2 == null || itemstack2.count == 0) {
            if (event.getItem().equals(oitemstack)) {
                iinventory.update();
            } else {
                iinventory.setItem(i, itemstack1);
            }
            // CraftBukkit end

            return true;
        }

        iinventory.setItem(i, itemstack1);
    }

    return false;
}
 
開發者ID:OvercastNetwork,項目名稱:CraftBukkit,代碼行數:49,代碼來源:TileEntityHopper.java

示例4: dispense

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
public void dispense(World world, int i, int j, int k) { // CraftBukkit - protected -> public
    SourceBlock sourceblock = new SourceBlock(world, i, j, k);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) sourceblock.getTileEntity();

    if (tileentitydispenser != null) {
        int l = tileentitydispenser.j();

        if (l < 0) {
            world.triggerEffect(1001, i, j, k, 0);
        } else {
            ItemStack itemstack = tileentitydispenser.getItem(l);
            int i1 = world.getData(i, j, k) & 7;
            IInventory iinventory = TileEntityHopper.getInventoryAt(world, (double) (i + Facing.b[i1]), (double) (j + Facing.c[i1]), (double) (k + Facing.d[i1]));
            ItemStack itemstack1;

            if (iinventory != null) {
                // CraftBukkit start - Fire event when pushing items into other inventories
                CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().a(1));

                org.bukkit.inventory.Inventory destinationInventory;
                // Have to special case large chests as they work oddly
                if (iinventory instanceof InventoryLargeChest) {
                    destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
                } else {
                    destinationInventory = iinventory.getOwner().getInventory();
                }

                InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                world.getServer().getPluginManager().callEvent(event);
                if (event.isCancelled()) {
                    return;
                }
                itemstack1 = TileEntityHopper.addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.OPPOSITE_FACING[i1]);
                if (event.getItem().equals(oitemstack) && itemstack1 == null) {
                    // CraftBukkit end
                    itemstack1 = itemstack.cloneItemStack();
                    if (--itemstack1.count == 0) {
                        itemstack1 = null;
                    }
                } else {
                    itemstack1 = itemstack.cloneItemStack();
                }
            } else {
                itemstack1 = this.cX.a(sourceblock, itemstack);
                if (itemstack1 != null && itemstack1.count == 0) {
                    itemstack1 = null;
                }
            }

            tileentitydispenser.setItem(l, itemstack1);
        }
    }
}
 
開發者ID:AlmuraDev,項目名稱:Almura-Server,代碼行數:54,代碼來源:BlockDropper.java

示例5: u

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
private boolean u() {
    IInventory iinventory = this.v();

    if (iinventory == null) {
        return false;
    } else {
        for (int i = 0; i < this.getSize(); ++i) {
            if (this.getItem(i) != null) {
                ItemStack itemstack = this.getItem(i).cloneItemStack();
                // CraftBukkit start - Call event when pushing items into other inventories
                CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1));

                Inventory destinationInventory;
                // Have to special case large chests as they work oddly
                if (iinventory instanceof InventoryLargeChest) {
                    destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
                } else {
                    destinationInventory = iinventory.getOwner().getInventory();
                }

                InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                this.getWorld().getServer().getPluginManager().callEvent(event);
                if (event.isCancelled()) {
                    this.setItem(i, itemstack);
                    this.c(world.spigotConfig.hopperTransfer); // Spigot
                    return false;
                }
                ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.OPPOSITE_FACING[BlockHopper.c(this.p())]);

                if (itemstack1 == null || itemstack1.count == 0) {
                    if (event.getItem().equals(oitemstack)) {
                        iinventory.update();
                    } else {
                        this.setItem(i, itemstack);
                    }
                    // CraftBukkit end
                    return true;
                }

                this.setItem(i, itemstack);
            }
        }

        return false;
    }
}
 
開發者ID:AlmuraDev,項目名稱:Almura-Server,代碼行數:47,代碼來源:TileEntityHopper.java

示例6: tryTakeInItemFromSlot

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
private static boolean tryTakeInItemFromSlot(IHopper ihopper, IInventory iinventory, int i, int j) {
    ItemStack itemstack = iinventory.getItem(i);

    if (itemstack != null && canTakeItemFromInventory(iinventory, itemstack, i, j)) {
        ItemStack itemstack1 = itemstack.cloneItemStack();
        // CraftBukkit start - Call event on collection of items from inventories into the hopper
        CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1));

        Inventory sourceInventory;
        // Have to special case large chests as they work oddly
        if (iinventory instanceof InventoryLargeChest) {
            sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
        } else {
            sourceInventory = iinventory.getOwner().getInventory();
        }

        InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);

        ihopper.getWorld().getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            iinventory.setItem(i, itemstack1);

            if (ihopper instanceof TileEntityHopper) {
                ((TileEntityHopper) ihopper).c(ihopper.getWorld().spigotConfig.hopperTransfer); // Spigot
            } else if (ihopper instanceof EntityMinecartHopper) {
                ((EntityMinecartHopper) ihopper).l(ihopper.getWorld().spigotConfig.hopperTransfer / 2); // Spigot
            }

            return false;
        }
        ItemStack itemstack2 = addItem(ihopper, CraftItemStack.asNMSCopy(event.getItem()), -1);

        if (itemstack2 == null || itemstack2.count == 0) {
            if (event.getItem().equals(oitemstack)) {
                iinventory.update();
            } else {
                iinventory.setItem(i, itemstack1);
            }
            // CraftBukkit end

            return true;
        }

        iinventory.setItem(i, itemstack1);
    }

    return false;
}
 
開發者ID:AlmuraDev,項目名稱:Almura-Server,代碼行數:49,代碼來源:TileEntityHopper.java

示例7: y

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
private boolean y() {
    IInventory iinventory = this.z();

    if (iinventory == null) {
        return false;
    } else {
        int i = Facing.OPPOSITE_FACING[BlockHopper.b(this.p())];

        if (this.a(iinventory, i)) {
            return false;
        } else {
            for (int j = 0; j < this.getSize(); ++j) {
                if (this.getItem(j) != null) {
                    ItemStack itemstack = this.getItem(j).cloneItemStack();
                    // CraftBukkit start - Call event when pushing items into other inventories
                    CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(j, world.spigotConfig.hopperAmount)); // Spigot

                    Inventory destinationInventory;
                    // Have to special case large chests as they work oddly
                    if (iinventory instanceof InventoryLargeChest) {
                        destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
                    } else {
                        destinationInventory = iinventory.getOwner().getInventory();
                    }

                    InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                    this.getWorld().getServer().getPluginManager().callEvent(event);
                    if (event.isCancelled()) {
                        this.setItem(j, itemstack);
                        this.c(world.spigotConfig.hopperTransfer); // Spigot
                        return false;
                    }
                    int origCount = event.getItem().getAmount(); // Spigot
                    ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), i);
                    if (itemstack1 == null || itemstack1.count == 0) {
                        if (event.getItem().equals(oitemstack)) {
                            iinventory.update();
                        } else {
                            this.setItem(j, itemstack);
                        }
                        // CraftBukkit end
                        return true;
                    }
                    itemstack.count -= origCount - itemstack1.count; // Spigot
                    this.setItem(j, itemstack);
                }
            }

            return false;
        }
    }
}
 
開發者ID:pvginkel,項目名稱:Tweakkit-Server,代碼行數:53,代碼來源:TileEntityHopper.java

示例8: tryTakeInItemFromSlot

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
private static boolean tryTakeInItemFromSlot(IHopper ihopper, IInventory iinventory, int i, int j) {
    ItemStack itemstack = iinventory.getItem(i);

    if (itemstack != null && canTakeItemFromInventory(iinventory, itemstack, i, j)) {
        ItemStack itemstack1 = itemstack.cloneItemStack();
        // CraftBukkit start - Call event on collection of items from inventories into the hopper
        CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, ihopper.getWorld().spigotConfig.hopperAmount)); // Spigot

        Inventory sourceInventory;
        // Have to special case large chests as they work oddly
        if (iinventory instanceof InventoryLargeChest) {
            sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
        } else {
            sourceInventory = iinventory.getOwner().getInventory();
        }

        InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);

        ihopper.getWorld().getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            iinventory.setItem(i, itemstack1);

            if (ihopper instanceof TileEntityHopper) {
                ((TileEntityHopper) ihopper).c(ihopper.getWorld().spigotConfig.hopperTransfer); // Spigot
            } else if (ihopper instanceof EntityMinecartHopper) {
                ((EntityMinecartHopper) ihopper).l(ihopper.getWorld().spigotConfig.hopperTransfer / 2); // Spigot
            }

            return false;
        }
        int origCount = event.getItem().getAmount(); // Spigot
        ItemStack itemstack2 = addItem(ihopper, CraftItemStack.asNMSCopy(event.getItem()), -1);

        if (itemstack2 == null || itemstack2.count == 0) {
            if (event.getItem().equals(oitemstack)) {
                iinventory.update();
            } else {
                iinventory.setItem(i, itemstack1);
            }
            // CraftBukkit end

            return true;
        }
        itemstack1.count -= origCount - itemstack2.count; // Spigot

        iinventory.setItem(i, itemstack1);
    }

    return false;
}
 
開發者ID:pvginkel,項目名稱:Tweakkit-Server,代碼行數:51,代碼來源:TileEntityHopper.java

示例9: func_149941_e

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
public void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_)   // CraftBukkit - protected -> public
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int l = tileentitydispenser.func_146017_i();

        if (l < 0)
        {
            p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(l);
            int i1 = p_149941_1_.getBlockMetadata(p_149941_2_, p_149941_3_, p_149941_4_) & 7;
            IInventory iinventory = TileEntityHopper.func_145893_b(p_149941_1_, (double)(p_149941_2_ + Facing.offsetsXForSide[i1]), (double)(p_149941_3_ + Facing.offsetsYForSide[i1]), (double)(p_149941_4_ + Facing.offsetsZForSide[i1]));
            ItemStack itemstack1;

            if (iinventory != null)
            {
                // CraftBukkit start - Fire event when pushing items into other inventories
                CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.copy().splitStack(1));
                org.bukkit.inventory.Inventory destinationInventory;

                // Have to special case large chests as they work oddly
                if (iinventory instanceof InventoryLargeChest)
                {
                    destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
                }
                else
                {
                    destinationInventory = iinventory.getOwner().getInventory();
                }

                InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                p_149941_1_.getServer().getPluginManager().callEvent(event);

                if (event.isCancelled())
                {
                    return;
                }

                itemstack1 = TileEntityHopper.func_145889_a(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.oppositeSide[i1]);

                if (event.getItem().equals(oitemstack) && itemstack1 == null)
                {
                    // CraftBukkit end
                    itemstack1 = itemstack.copy();

                    if (--itemstack1.stackSize == 0)
                    {
                        itemstack1 = null;
                    }
                }
                else
                {
                    itemstack1 = itemstack.copy();
                }
            }
            else
            {
                itemstack1 = this.field_149947_P.dispense(blocksourceimpl, itemstack);

                if (itemstack1 != null && itemstack1.stackSize == 0)
                {
                    itemstack1 = null;
                }
            }

            tileentitydispenser.setInventorySlotContents(l, itemstack1);
        }
    }
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:76,代碼來源:BlockDropper.java

示例10: func_145892_a

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
private static boolean func_145892_a(IHopper p_145892_0_, IInventory p_145892_1_, int p_145892_2_, int p_145892_3_)
{
    ItemStack itemstack = p_145892_1_.getStackInSlot(p_145892_2_);

    if (itemstack != null && func_145890_b(p_145892_1_, itemstack, p_145892_2_, p_145892_3_))
    {
        ItemStack itemstack1 = itemstack.copy();
        // CraftBukkit start - Call event on collection of items from inventories into the hopper
        CraftItemStack oitemstack = CraftItemStack.asCraftMirror(p_145892_1_.decrStackSize(p_145892_2_, 1));
        Inventory sourceInventory;

        // Have to special case large chests as they work oddly
        if (p_145892_1_ instanceof InventoryLargeChest)
        {
            sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) p_145892_1_);
        }
        else
        {
            // Cauldron start - support mod inventories, with no owners
            try
            {
                if (p_145892_1_.getOwner() != null)
                {
                    sourceInventory = p_145892_1_.getOwner().getInventory();
                } 
                else
                {
                    // TODO: create a mod inventory for passing to the event, instead of null
                    sourceInventory = null;
                }
            }
            catch (AbstractMethodError e)
            {
                sourceInventory = null;
            }
            // Cauldron end
        }

        InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), p_145892_0_.getOwner().getInventory(), false);
        p_145892_0_.getWorldObj().getServer().getPluginManager().callEvent(event);

        if (event.isCancelled())
        {
            p_145892_1_.setInventorySlotContents(p_145892_2_, itemstack1);

            if (p_145892_0_ instanceof TileEntityHopper)
            {
                ((TileEntityHopper) p_145892_0_).func_145896_c(p_145892_0_.getWorldObj().spigotConfig.hopperTransfer); // Spigot
            }
            else if (p_145892_0_ instanceof EntityMinecartHopper)
            {
                ((EntityMinecartHopper) p_145892_0_).setDisplayTileData(p_145892_0_.getWorldObj().spigotConfig.hopperTransfer / 2); // Spigot
            }

            return false;
        }

        ItemStack itemstack2 = func_145889_a(p_145892_0_, CraftItemStack.asNMSCopy(event.getItem()), -1);

        if (itemstack2 == null || itemstack2.stackSize == 0)
        {
            if (event.getItem().equals(oitemstack))
            {
                p_145892_1_.markDirty();
            }
            else
            {
                p_145892_1_.setInventorySlotContents(p_145892_2_, itemstack1);
            }

            // CraftBukkit end
            return true;
        }

        p_145892_1_.setInventorySlotContents(p_145892_2_, itemstack1);
    }

    return false;
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:80,代碼來源:TileEntityHopper.java

示例11: dispense

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
public void dispense(World world, BlockPosition blockposition) {
    SourceBlock sourceblock = new SourceBlock(world, blockposition);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) sourceblock.getTileEntity();

    if (tileentitydispenser != null) {
        int i = tileentitydispenser.m();

        if (i < 0) {
            world.triggerEffect(1001, blockposition, 0);
        } else {
            ItemStack itemstack = tileentitydispenser.getItem(i);

            if (itemstack != null) {
                EnumDirection enumdirection = (EnumDirection) world.getType(blockposition).get(BlockDropper.FACING);
                BlockPosition blockposition1 = blockposition.shift(enumdirection);
                IInventory iinventory = TileEntityHopper.b(world, (double) blockposition1.getX(), (double) blockposition1.getY(), (double) blockposition1.getZ());
                ItemStack itemstack1;

                if (iinventory == null) {
                    itemstack1 = this.e.a(sourceblock, itemstack);
                    if (itemstack1 != null && itemstack1.count <= 0) {
                        itemstack1 = null;
                    }
                } else {
                    // CraftBukkit start - Fire event when pushing items into other inventories
                    CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().cloneAndSubtract(1));

                    org.bukkit.inventory.Inventory destinationInventory;
                    // Have to special case large chests as they work oddly
                    if (iinventory instanceof InventoryLargeChest) {
                        destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
                    } else {
                        destinationInventory = iinventory.getOwner().getInventory();
                    }

                    InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                    world.getServer().getPluginManager().callEvent(event);
                    if (event.isCancelled()) {
                        return;
                    }
                    itemstack1 = TileEntityHopper.addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite());
                    if (event.getItem().equals(oitemstack) && itemstack1 == null) {
                        // CraftBukkit end
                        itemstack1 = itemstack.cloneItemStack();
                        if (--itemstack1.count <= 0) {
                            itemstack1 = null;
                        }
                    } else {
                        itemstack1 = itemstack.cloneItemStack();
                    }
                }

                tileentitydispenser.setItem(i, itemstack1);
            }
        }
    }
}
 
開發者ID:bergerkiller,項目名稱:SpigotSource,代碼行數:58,代碼來源:BlockDropper.java

示例12: H

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
private boolean H() {
    IInventory iinventory = this.I();

    if (iinventory == null) {
        return false;
    } else {
        EnumDirection enumdirection = BlockHopper.e(this.u()).opposite();

        if (this.a(iinventory, enumdirection)) {
            return false;
        } else {
            for (int i = 0; i < this.getSize(); ++i) {
                if (this.getItem(i) != null) {
                    ItemStack itemstack = this.getItem(i).cloneItemStack();
                    // ItemStack itemstack1 = addItem(iinventory, this.splitStack(i, 1), enumdirection);

                    // CraftBukkit start - Call event when pushing items into other inventories
                    CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, world.spigotConfig.hopperAmount)); // Spigot

                    Inventory destinationInventory;
                    // Have to special case large chests as they work oddly
                    if (iinventory instanceof InventoryLargeChest) {
                        destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
                    } else {
                        destinationInventory = iinventory.getOwner().getInventory();
                    }

                    InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                    this.getWorld().getServer().getPluginManager().callEvent(event);
                    if (event.isCancelled()) {
                        this.setItem(i, itemstack);
                        this.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
                        return false;
                    }
                    int origCount = event.getItem().getAmount(); // Spigot
                    ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);

                    if (itemstack1 == null || itemstack1.count == 0) {
                        if (event.getItem().equals(oitemstack)) {
                            iinventory.update();
                        } else {
                            this.setItem(i, itemstack);
                        }
                        // CraftBukkit end
                        return true;
                    }
                    itemstack.count -= origCount - itemstack1.count; // Spigot
                    this.setItem(i, itemstack);
                }
            }

            return false;
        }
    }
}
 
開發者ID:bergerkiller,項目名稱:SpigotSource,代碼行數:56,代碼來源:TileEntityHopper.java

示例13: a

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
private static boolean a(IHopper ihopper, IInventory iinventory, int i, EnumDirection enumdirection) {
    ItemStack itemstack = iinventory.getItem(i);

    if (itemstack != null && b(iinventory, itemstack, i, enumdirection)) {
        ItemStack itemstack1 = itemstack.cloneItemStack();
        // ItemStack itemstack2 = addItem(ihopper, iinventory.splitStack(i, 1), (EnumDirection) null);
        // CraftBukkit start - Call event on collection of items from inventories into the hopper
        CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, ihopper.getWorld().spigotConfig.hopperAmount)); // Spigot

        Inventory sourceInventory;
        // Have to special case large chests as they work oddly
        if (iinventory instanceof InventoryLargeChest) {
            sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
        } else {
            sourceInventory = iinventory.getOwner().getInventory();
        }

        InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);

        ihopper.getWorld().getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            iinventory.setItem(i, itemstack1);

            if (ihopper instanceof TileEntityHopper) {
                ((TileEntityHopper) ihopper).setCooldown(ihopper.getWorld().spigotConfig.hopperTransfer); // Spigot
            } else if (ihopper instanceof EntityMinecartHopper) {
                ((EntityMinecartHopper) ihopper).setCooldown(ihopper.getWorld().spigotConfig.hopperTransfer / 2); // Spigot
            }
            return false;
        }
        int origCount = event.getItem().getAmount(); // Spigot
        ItemStack itemstack2 = addItem(ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);

        if (itemstack2 == null || itemstack2.count == 0) {
            if (event.getItem().equals(oitemstack)) {
                iinventory.update();
            } else {
                iinventory.setItem(i, itemstack1);
            }
            // CraftBukkit end
            return true;
        }
        itemstack1.count -= origCount - itemstack2.count; // Spigot

        iinventory.setItem(i, itemstack1);
    }

    return false;
}
 
開發者ID:bergerkiller,項目名稱:SpigotSource,代碼行數:50,代碼來源:TileEntityHopper.java

示例14: dispense

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
public void dispense(World world, int i, int j, int k) { // CraftBukkit - protected -> public
    SourceBlock sourceblock = new SourceBlock(world, i, j, k);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser) sourceblock.getTileEntity();

    if (tileentitydispenser != null) {
        int l = tileentitydispenser.j();

        if (l < 0) {
            world.triggerEffect(1001, i, j, k, 0);
        } else {
            ItemStack itemstack = tileentitydispenser.getItem(l);
            int i1 = world.getData(i, j, k) & 7;
            IInventory iinventory = TileEntityHopper.getInventoryAt(world, (double) (i + Facing.b[i1]), (double) (j + Facing.c[i1]), (double) (k + Facing.d[i1]));
            ItemStack itemstack1;

            if (iinventory != null) {
                // CraftBukkit start - Fire event when pushing items into other inventories
                CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().a(1));

                org.bukkit.inventory.Inventory destinationInventory;
                // Have to special case large chests as they work oddly
                if (iinventory instanceof InventoryLargeChest) {
                    destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
                } else {
                    destinationInventory = iinventory.getOwner().getInventory();
                }

                InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                world.getServer().getPluginManager().callEvent(event);
                if (event.isCancelled()) {
                    return;
                }
                itemstack1 = TileEntityHopper.addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.OPPOSITE_FACING[i1]);
                if (event.getItem().equals(oitemstack) && itemstack1 == null) {
                    // CraftBukkit end
                    itemstack1 = itemstack.cloneItemStack();
                    if (--itemstack1.count == 0) {
                        itemstack1 = null;
                    }
                } else {
                    itemstack1 = itemstack.cloneItemStack();
                }
            } else {
                itemstack1 = this.cR.a(sourceblock, itemstack);
                if (itemstack1 != null && itemstack1.count == 0) {
                    itemstack1 = null;
                }
            }

            tileentitydispenser.setItem(l, itemstack1);
        }
    }
}
 
開發者ID:didoupimpon,項目名稱:Craft-city,代碼行數:54,代碼來源:BlockDropper.java

示例15: u

import org.bukkit.event.inventory.InventoryMoveItemEvent; //導入方法依賴的package包/類
private boolean u() {
    IInventory iinventory = this.v();

    if (iinventory == null) {
        return false;
    } else {
        for (int i = 0; i < this.getSize(); ++i) {
            if (this.getItem(i) != null) {
                ItemStack itemstack = this.getItem(i).cloneItemStack();
                // CraftBukkit start - Call event when pushing items into other inventories
                CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1));

                Inventory destinationInventory;
                // Have to special case large chests as they work oddly
                if (iinventory instanceof InventoryLargeChest) {
                    destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
                } else {
                    destinationInventory = iinventory.getOwner().getInventory();
                }

                InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
                this.getWorld().getServer().getPluginManager().callEvent(event);
                if (event.isCancelled()) {
                    this.setItem(i, itemstack);
                    this.c(8); // Delay hopper checks
                    return false;
                }
                ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.OPPOSITE_FACING[BlockHopper.c(this.p())]);

                if (itemstack1 == null || itemstack1.count == 0) {
                    if (event.getItem().equals(oitemstack)) {
                        iinventory.update();
                    } else {
                        this.setItem(i, itemstack);
                    }
                    // CraftBukkit end
                    return true;
                }

                this.setItem(i, itemstack);
            }
        }

        return false;
    }
}
 
開發者ID:didoupimpon,項目名稱:Craft-city,代碼行數:47,代碼來源:TileEntityHopper.java


注:本文中的org.bukkit.event.inventory.InventoryMoveItemEvent.isCancelled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。