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


Java ForgeEventFactory.onItemUseFinish方法代碼示例

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


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

示例1: insertItem

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
    EntityPlayer player = getPlayer();
    if (player == null || getFoodValue(stack) <= 0) return stack;
    if (!okToFeed(stack, player)) return stack;

    if (simulate) return ItemStack.EMPTY;

    int startValue = stack.getCount();
    ItemStack remainingItem = stack;
    while (stack.getCount() > 0) {
        remainingItem = stack.onItemUseFinish(player.world, player);
        remainingItem = ForgeEventFactory.onItemUseFinish(player, stack, 0, remainingItem);
        if (remainingItem.getCount() > 0 && (remainingItem != stack || remainingItem.getCount() != startValue)) {
            if (!player.inventory.addItemStackToInventory(remainingItem) && remainingItem.getCount() > 0) {
                player.dropItem(remainingItem, false);
            }
        }
        if (stack.getCount() == startValue) break;
    }
    return remainingItem.getCount() > 0 ? remainingItem : ItemStack.EMPTY;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:24,代碼來源:TileEntityAerialInterface.java

示例2: onItemUseFinish

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
protected void onItemUseFinish()
{
	if (this.itemInUse != null)
	{
		updateItemUse(this.itemInUse, 16);
		int i = this.itemInUse.stackSize;
		ItemStack itemstack = this.itemInUse.onFoodEaten(this.worldObj, this);

		itemstack = ForgeEventFactory.onItemUseFinish(this, this.itemInUse, this.itemInUseCount, itemstack);
		if ((itemstack != this.itemInUse) || ((itemstack != null) && (itemstack.stackSize != i)))
		{
			this.inventory.mainInventory[this.inventory.currentItem] = itemstack;
			if ((itemstack != null) && (itemstack.stackSize == 0)) {
				this.inventory.mainInventory[this.inventory.currentItem] = null;
			}
		}
		clearItemInUse();
	}
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:20,代碼來源:EntityPlayer.java

示例3: onItemUseFinish

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
protected void onItemUseFinish()
{
    if (this.itemInUse != null)
    {
        this.updateItemUse(this.itemInUse, 16);
        int i = this.itemInUse.stackSize;
        ItemStack itemstack = this.itemInUse.onFoodEaten(this.worldObj, this);

        itemstack = ForgeEventFactory.onItemUseFinish(this, itemInUse, itemInUseCount, itemstack);

        if (itemstack != this.itemInUse || itemstack != null && itemstack.stackSize != i)
        {
            this.inventory.mainInventory[this.inventory.currentItem] = itemstack;

            if (itemstack != null && itemstack.stackSize == 0)
            {
                this.inventory.mainInventory[this.inventory.currentItem] = null;
            }
        }

        this.clearItemInUse();
    }
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:24,代碼來源:EntityPlayer.java

示例4: setInventorySlotContents

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
@Override
public void setInventorySlotContents(int slot, ItemStack itemStack){
    if(slot < 4) {
        inventory[slot] = itemStack;
        if(itemStack != null && itemStack.stackSize > getInventoryStackLimit()) {
            itemStack.stackSize = getInventoryStackLimit();
        }
    } else {
        EntityPlayer player = getPlayer();
        if(dispenserUpgradeInserted) {
            if(itemStack != null) {
                int startValue = itemStack.stackSize;
                while(itemStack.stackSize > 0) {
                    ItemStack remainingItem = itemStack.onFoodEaten(player.worldObj, player);
                    remainingItem = ForgeEventFactory.onItemUseFinish(player, itemStack, 0, remainingItem);
                    if(remainingItem != null && remainingItem.stackSize > 0 && (remainingItem != itemStack || remainingItem.stackSize != startValue)) {
                        if(!player.inventory.addItemStackToInventory(remainingItem) && remainingItem.stackSize > 0) {
                            player.dropPlayerItemWithRandomChoice(remainingItem, false);
                        }
                    }
                    if(itemStack.stackSize == startValue) break;
                }
            }
        } else {
            InventoryPlayer inventoryPlayer = player != null ? player.inventory : null;
            if(inventoryPlayer != null) {
                inventoryPlayer.setInventorySlotContents(slot - 4, itemStack);
            } else if(worldObj != null && !worldObj.isRemote) {
                EntityItem item = new EntityItem(worldObj, xCoord, yCoord, zCoord, itemStack);
                worldObj.spawnEntityInWorld(item);
            }
        }
    }

}
 
開發者ID:MineMaarten,項目名稱:PneumaticCraft,代碼行數:36,代碼來源:TileEntityAerialInterface.java

示例5: onItemUseFinish

import net.minecraftforge.event.ForgeEventFactory; //導入方法依賴的package包/類
protected void onItemUseFinish()
{
    if (this.itemInUse != null)
    {
        this.updateItemUse(this.itemInUse, 16);
        int i = this.itemInUse.stackSize;
        // CraftBukkit start
        org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.itemInUse);
        PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
        worldObj.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled())
        {
            // Update client
            if (this instanceof EntityPlayerMP)
            {
                ((EntityPlayerMP) this).playerNetServerHandler.sendPacket(new S2FPacketSetSlot((byte) 0, openContainer.getSlotFromInventory((IInventory) this.inventory, this.inventory.currentItem).slotIndex, this.itemInUse));
                // Spigot Start
                ((EntityPlayerMP) this).getBukkitEntity().updateInventory();
                ((EntityPlayerMP) this).getBukkitEntity().updateScaledHealth();
                // Spigot End
            }

            return;
        }

        // Plugin modified the item, process it but don't remove it
        if (!craftItem.equals(event.getItem()))
        {
            CraftItemStack.asNMSCopy(event.getItem()).onFoodEaten(this.worldObj, this);

            // Update client
            if (this instanceof EntityPlayerMP)
            {
                ((EntityPlayerMP) this).playerNetServerHandler.sendPacket(new S2FPacketSetSlot((byte) 0, openContainer.getSlotFromInventory((IInventory) this.inventory, this.inventory.currentItem).slotIndex, this.itemInUse));
            }

            return;
        }

        // CraftBukkit end
        ItemStack itemstack = this.itemInUse.onFoodEaten(this.worldObj, this);

        itemstack = ForgeEventFactory.onItemUseFinish(this, itemInUse, itemInUseCount, itemstack);

        if (itemstack != this.itemInUse || itemstack != null && itemstack.stackSize != i)
        {
            this.inventory.mainInventory[this.inventory.currentItem] = itemstack;

            if (itemstack != null && itemstack.stackSize == 0)
            {
                this.inventory.mainInventory[this.inventory.currentItem] = null;
            }
        }

        this.clearItemInUse();
    }
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:59,代碼來源:EntityPlayer.java


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