当前位置: 首页>>代码示例>>Java>>正文


Java Slot.onTake方法代码示例

本文整理汇总了Java中net.minecraft.inventory.Slot.onTake方法的典型用法代码示例。如果您正苦于以下问题:Java Slot.onTake方法的具体用法?Java Slot.onTake怎么用?Java Slot.onTake使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.inventory.Slot的用法示例。


在下文中一共展示了Slot.onTake方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
@Nonnull
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
    Slot srcSlot = inventorySlots.get(slot);
    if (srcSlot == null || !srcSlot.getHasStack()) {
        return ItemStack.EMPTY;
    }
    ItemStack srcStack = srcSlot.getStack();
    ItemStack copyOfSrcStack = srcStack.copy();

    if (slot < playerSlotsStart) {
        if (!mergeItemStack(srcStack, playerSlotsStart, playerSlotsStart + 36, false))
            return ItemStack.EMPTY;
    } else {
        if (!mergeItemStack(srcStack, 0, playerSlotsStart, false))
            return ItemStack.EMPTY;
    }
    srcSlot.onSlotChange(srcStack, copyOfSrcStack);

    if (srcStack.isEmpty()) {
        srcSlot.putStack(ItemStack.EMPTY);
    } else {
        srcSlot.onSlotChanged();
    }

    srcSlot.onTake(player, srcStack);
    return copyOfSrcStack;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:29,代码来源:ContainerPneumaticBase.java

示例2: slotClickPhantom

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Nonnull
private ItemStack slotClickPhantom(Slot slot, int dragType, ClickType clickType, EntityPlayer player) {
    ItemStack stack = ItemStack.EMPTY;

    if (clickType == ClickType.CLONE && dragType == 2) {
        // middle-click: clear slot
        if (((IPhantomSlot) slot).canAdjust()) {
            slot.putStack(ItemStack.EMPTY);
        }
    } else if ((clickType == ClickType.PICKUP || clickType == ClickType.QUICK_MOVE) && (dragType == 0 || dragType == 1)) {
        // left or right-click...
        InventoryPlayer playerInv = player.inventory;
        slot.onSlotChanged();
        ItemStack stackSlot = slot.getStack();
        ItemStack stackHeld = playerInv.getItemStack();

        stack = stackSlot.copy();
        if (stackSlot.isEmpty()) {
            if (!stackHeld.isEmpty() && slot.isItemValid(stackHeld)) {
                fillPhantomSlot(slot, stackHeld, clickType, dragType);
            }
        } else if (stackHeld.isEmpty()) {
            adjustPhantomSlot(slot, clickType, dragType);
            slot.onTake(player, playerInv.getItemStack());
        } else if (slot.isItemValid(stackHeld)) {
            if (canStacksMerge(stackSlot, stackHeld)) {
                adjustPhantomSlot(slot, clickType, dragType);
            } else {
                fillPhantomSlot(slot, stackHeld, clickType, dragType);
            }
        }
    }
    return stack;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:35,代码来源:ContainerPneumaticBase.java

示例3: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Nonnull
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotIndex) {
    ItemStack stack = ItemStack.EMPTY;
    Slot srcSlot = inventorySlots.get(slotIndex);

    if (srcSlot != null && srcSlot.getHasStack()) {
        ItemStack stackInSlot = srcSlot.getStack();
        stack = stackInSlot.copy();

        if (slotIndex < 27) {
            if (!mergeItemStack(stackInSlot, 27, 36, false)) return ItemStack.EMPTY;
            srcSlot.onSlotChange(stackInSlot, stack);
        } else {
            if (!mergeItemStack(stackInSlot, 0, 27, false)) return ItemStack.EMPTY;
            srcSlot.onSlotChange(stackInSlot, stack);
        }

        if (stackInSlot.isEmpty()) {
            srcSlot.putStack(ItemStack.EMPTY);
        } else {
            srcSlot.onSlotChanged();
        }

        if (stackInSlot.getCount() == stack.getCount()) return ItemStack.EMPTY;

        srcSlot.onTake(par1EntityPlayer, stackInSlot);
    }

    return stack;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:32,代码来源:ContainerRefinery.java

示例4: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
 * Take a stack from the specified inventory slot.
 */
@Override
@Nullable
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
	ItemStack itemstack = ItemStack.EMPTY;
	Slot slot = this.inventorySlots.get(index);

	if (slot != null && slot.getHasStack()) {
		ItemStack itemstack1 = slot.getStack();
		itemstack = itemstack1.copy();

		if (index == 0) {
			if (!this.mergeItemStack(itemstack1, 1, 28, true))
				return ItemStack.EMPTY;

			slot.onSlotChange(itemstack1, itemstack);
		} else if (index >= 1 && index < 28) {
			if (!this.mergeItemStack(itemstack1, 0, 1, false))
				return ItemStack.EMPTY;
		} else if (!this.mergeItemStack(itemstack1, 1, 28, false))
			return ItemStack.EMPTY;

		if (itemstack1.isEmpty())
			slot.putStack(ItemStack.EMPTY);
		else
			slot.onSlotChanged();

		if (itemstack1.getCount() ==itemstack.getCount())
			return ItemStack.EMPTY;

		slot.onTake(playerIn, itemstack1);
	}

	return itemstack;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:38,代码来源:ContainerUpgrades.java

示例5: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int sourceSlotIndex) {
	Slot sourceSlot = inventorySlots.get(sourceSlotIndex);
	if (sourceSlot == null || !sourceSlot.getHasStack())
		return ItemStack.EMPTY;
	ItemStack sourceStack = sourceSlot.getStack();
	ItemStack copyOfSourceStack = sourceStack.copy();

	if (sourceSlotIndex >= VANILLA_FIRST_SLOT_INDEX && sourceSlotIndex < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) {
		if (!mergeItemStack(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT, false)) {
			return ItemStack.EMPTY;
		}
	} else if (sourceSlotIndex >= TE_INVENTORY_FIRST_SLOT_INDEX && sourceSlotIndex < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) {
		if (!mergeItemStack(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) {
			return ItemStack.EMPTY;
		}
	} else {
		System.err.print("Invalid slotIndex:" + sourceSlotIndex);
		return ItemStack.EMPTY;
	}

	if (sourceStack.getCount() == 0) {
		sourceSlot.putStack(ItemStack.EMPTY);
	} else {
		sourceSlot.onSlotChanged();
	}

	sourceSlot.onTake(player, sourceStack);
	return copyOfSourceStack;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:31,代码来源:ContainerStockCrate.java

示例6: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
	ItemStack previous = ItemStack.EMPTY;
	Slot slot = (Slot) this.inventorySlots.get(fromSlot);

	if (slot != null && slot.getHasStack()) {
		ItemStack current = slot.getStack();
		previous = current.copy();

		if (fromSlot < this.handler.getSlots()) {
			// From the block breaker inventory to player's inventory
			if (!this.mergeItemStack(current, handler.getSlots(), handler.getSlots() + 36, true))
				return ItemStack.EMPTY;
		} else {
			// From the player's inventory to block breaker's inventory
			if (current.getItem() == Items.ENCHANTED_BOOK) {
				if (!this.mergeItemStack(current, 9, handler.getSlots(), false))
					return ItemStack.EMPTY;
			}
			if (!this.mergeItemStack(current, 0, handler.getSlots(), false))
				return ItemStack.EMPTY;
		}

		if (current.getCount() == 0)
			slot.putStack(ItemStack.EMPTY);
		else
			slot.onSlotChanged();

		if (current.getCount() == previous.getCount())
			return null;
		slot.onTake(playerIn, current);
	}
	return previous;
}
 
开发者ID:IvanSteklow,项目名称:VanillaExtras,代码行数:35,代码来源:ContainerBlockBreaker.java

示例7: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
 * Take a stack from the specified inventory slot.
 */
@Override
@Nullable
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
	ItemStack itemstack = ItemStack.EMPTY;
	Slot slot = this.inventorySlots.get(index);

	if (slot != null && slot.getHasStack()) {
		ItemStack itemstack1 = slot.getStack();
		itemstack = itemstack1.copy();

		if (index > 9 && index < 19) {
			if (!this.mergeItemStack(itemstack1, 19, 55, true))
				return ItemStack.EMPTY;

			slot.onSlotChange(itemstack1, itemstack);
		} else if (index > 9) {
			if (itemstack1.getItem() instanceof ItemAmmo) {
				if (!this.mergeItemStack(itemstack1, 0, 9, false))
					return ItemStack.EMPTY;
			} else if (TileEntityFurnace.isItemFuel(itemstack1)) {
				if (!this.mergeItemStack(itemstack1, 9, 10, false))
					return ItemStack.EMPTY;
			} else if (index >= 19 && index < 46) {
				if (!this.mergeItemStack(itemstack1, 46, 55, false))
					return ItemStack.EMPTY;
			} else if (index >= 46 && index < 55 && !this.mergeItemStack(itemstack1, 19, 46, false))
				return ItemStack.EMPTY;
		} else if (!this.mergeItemStack(itemstack1, 19, 55, false))
			return ItemStack.EMPTY;

		if (itemstack1.isEmpty())
			slot.putStack(ItemStack.EMPTY);
		else
			slot.onSlotChanged();

		if (itemstack1.getCount() == itemstack.getCount())
			return ItemStack.EMPTY;

		slot.onTake(playerIn, itemstack1);
	}

	return itemstack;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:47,代码来源:ContainerAmmoFurnace.java

示例8: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int par2)
{
	ItemStack itemstack = null;
	Slot slot = (Slot)inventorySlots.get(par2);

	if (slot != null && slot.getHasStack())
	{
		ItemStack itemstack1 = slot.getStack();
		itemstack = itemstack1.copy();

		if (par2 == TileEntityKilnBase.SLOT_OUTPUT)
		{
			if (!mergeItemStack(itemstack1, TileEntityKilnBase.SLOT_OUTPUT + 1, 39, true))
			{
				return null;
			}
			slot.onSlotChange(itemstack1, itemstack);
		}
		else if (par2 != TileEntityKiln.SLOT_FUEL && par2 != TileEntityKiln.SLOT_INPUT)
		{
			if (KilnRecipeHandler.instance().getSmeltingResult(itemstack1) != null)
			{
				if (!mergeItemStack(itemstack1, TileEntityKiln.SLOT_INPUT, TileEntityKiln.SLOT_INPUT + 1, false))
				{
					return null;
				}
			}
			else if (FuelRegistry.getBurnTime(FuelConsumerType.KILN, itemstack1) > 0)
			{
				if (!mergeItemStack(itemstack1, TileEntityKiln.SLOT_FUEL, TileEntityKiln.SLOT_FUEL + 1, false))
				{
					return null;
				}
			}
			else if (par2 > TileEntityKiln.SLOT_OUTPUT && par2 < 30)
			{
				if (!mergeItemStack(itemstack1, 30, 39, false))
				{
					return null;
				}
			}
			else if (par2 >= 30 && par2 < 39 && !mergeItemStack(itemstack1, TileEntityKiln.SLOT_OUTPUT + 1, 30, false))
			{
				return null;
			}
		}
		else if (!mergeItemStack(itemstack1, TileEntityKiln.SLOT_OUTPUT + 1, 39, true))
		{
			return null;
		}
		if (itemstack1.getCount() == 0)
		{
			slot.putStack(null);
		}
		else
		{
			slot.onSlotChanged();
		}
		if (itemstack1.getCount() == itemstack.getCount())
		{
			return null;
		}
		slot.onTake(player, itemstack1);
	}
	return itemstack;
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:68,代码来源:ContainerKiln.java

示例9: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
 * Take a stack from the specified inventory slot.
 */
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = (Slot)this.inventorySlots.get(index);

    if (slot != null && slot.getHasStack())
    {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();

        if (index < 9)
        {
            if (!this.mergeItemStack(itemstack1, 9, 45, true))
            {
                return ItemStack.EMPTY;
            }

            slot.onSlotChange(itemstack1, itemstack);
        }
        else if (index >= 9)
        {
            if (TileEntityFurnace.getItemBurnTime(itemstack1) > 0)
            {
                if (!this.mergeItemStack(itemstack1, 0, 9, false))
                {
                    return ItemStack.EMPTY;
                }
            }
            else if (index >= 9 && index < 36)
            {
                if (!this.mergeItemStack(itemstack1, 36, 45, false))
                {
                    return ItemStack.EMPTY;
                }
            }
            else if (index >= 36 && index < 45 && !this.mergeItemStack(itemstack1, 9, 36, false))
            {
                return ItemStack.EMPTY;
            }
        }
        else if (!this.mergeItemStack(itemstack1, 9, 36, false))
        {
            return ItemStack.EMPTY;
        }

        if (itemstack1.isEmpty())
        {
            slot.putStack(ItemStack.EMPTY);
        }
        else
        {
            slot.onSlotChanged();
        }

        if (itemstack1.getCount() == itemstack.getCount())
        {
            return ItemStack.EMPTY;
        }

        slot.onTake(playerIn, itemstack1);
    }

    return itemstack;
}
 
开发者ID:ArtixAllMighty,项目名称:ExSartagine,代码行数:68,代码来源:ContainerRange.java

示例10: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
 * Take a stack from the specified inventory slot.
 */
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
	ItemStack itemstack = ItemStack.EMPTY;
	Slot slot = (Slot)this.inventorySlots.get(index);

	if (slot != null && slot.getHasStack())
	{
		ItemStack itemstack1 = slot.getStack();
		itemstack = itemstack1.copy();

		if (index == 1 || index == 2)
		{
			if (!this.mergeItemStack(itemstack1, 3, 39, true))
			{
				return ItemStack.EMPTY;
			}

			slot.onSlotChange(itemstack1, itemstack);
		}
		else if (index != 0)
		{
			if (itemstack1.getItem() instanceof ItemBlock)
			{
				for(ItemStack stack : ores)
					if(OreDictionary.itemMatches(stack, itemstack1, false))
					{
						if (!this.mergeItemStack(itemstack1, 0, 1, false))
						{
							return ItemStack.EMPTY;
						}
						break;
					}
			}
			else if (index >= 3 && index < 30)
			{
				if (!this.mergeItemStack(itemstack1, 30, 39, false))
				{
					return ItemStack.EMPTY;
				}
			}
			else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
			{
				return ItemStack.EMPTY;
			}
		}
		else if (!this.mergeItemStack(itemstack1, 3, 39, false))
		{
			return ItemStack.EMPTY;
		}

		if (itemstack1.isEmpty())
		{
			slot.putStack(ItemStack.EMPTY);
		}
		else
		{
			slot.onSlotChanged();
		}

		if (itemstack1.getCount() == itemstack.getCount())
		{
			return ItemStack.EMPTY;
		}

		slot.onTake(playerIn, itemstack1);
	}

	return itemstack;
}
 
开发者ID:ArtixAllMighty,项目名称:ExSartagine,代码行数:73,代码来源:ContainerSmelter.java

示例11: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
 * Take a stack from the specified inventory slot.
 */
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = (Slot)this.inventorySlots.get(index);

    if (slot != null && slot.getHasStack())
    {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();

        if (index == 1)
        {
            if (!this.mergeItemStack(itemstack1, 2, 38, true))
            {
                return ItemStack.EMPTY;
            }

            slot.onSlotChange(itemstack1, itemstack);
        }
        else if (index != 0)
        {
        	boolean flag = false;
        	int[] ids = OreDictionary.getOreIDs(itemstack1);
        	for(int id: ids)
        		if(OreDictionary.getOreName(id).contains("food")){
        			flag = true;
        			break;
        		}
            if ((itemstack1.getItem() instanceof ItemFood || flag) && !FurnaceRecipes.instance().getSmeltingResult(itemstack1).isEmpty())
            {
                if (!this.mergeItemStack(itemstack1, 0, 1, false))
                {
                    return ItemStack.EMPTY;
                }
            }
            else if (index >= 2 && index < 29)
            {
                if (!this.mergeItemStack(itemstack1, 29, 38, false))
                {
                    return ItemStack.EMPTY;
                }
            }
            else if (index >= 29 && index < 38 && !this.mergeItemStack(itemstack1, 2, 29, false))
            {
                return ItemStack.EMPTY;
            }
        }
        else if (!this.mergeItemStack(itemstack1, 2, 38, false))
        {
            return ItemStack.EMPTY;
        }

        if (itemstack1.isEmpty())
        {
            slot.putStack(ItemStack.EMPTY);
        }
        else
        {
            slot.onSlotChanged();
        }

        if (itemstack1.getCount() == itemstack.getCount())
        {
            return ItemStack.EMPTY;
        }

        slot.onTake(playerIn, itemstack1);
    }

    return itemstack;
}
 
开发者ID:ArtixAllMighty,项目名称:ExSartagine,代码行数:75,代码来源:ContainerPan.java

示例12: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int fromId)
{
	ItemStack movedStackDupe = null;
	Slot slot = (Slot)inventorySlots.get(fromId);

	if (slot != null && slot.getHasStack())
	{
		ItemStack movedStack = slot.getStack();
		movedStackDupe = movedStack.copy();

		if (fromId == TileEntitySmelter.OUTPUT)
		{
			if (!mergeItemStack(movedStack, 4, 40, true))
			{
				return null;
			}
			slot.onSlotChange(movedStack, movedStackDupe);
		}
		else if (fromId != TileEntitySmelter.FUEL && fromId != TileEntitySmelter.INPUT &&
				fromId != TileEntitySmelter.BOOSTER)
		{
			if (SmelterRecipeHandler.instance().getSmeltingResult(movedStack) != null)
			{
				if (!mergeItemStack(movedStack, TileEntitySmelter.INPUT, TileEntitySmelter.INPUT + 1, false))
				{
					return null;
				}
			}
			else if (movedStack.getItem() == Item.getItemFromBlock(Blocks.GRAVEL))
			{
				if (!mergeItemStack(movedStack, TileEntitySmelter.BOOSTER, TileEntitySmelter.BOOSTER + 1, false))
				{
					return null;
				}
			}
			else if (FuelRegistry.getBurnTime(FuelConsumerType.SMELTER, movedStack) > 0)
			{
				if (!mergeItemStack(movedStack, TileEntitySmelter.FUEL, TileEntitySmelter.FUEL + 1, false))
				{
					return null;
				}
			}
			else if (fromId >= 4 && fromId < 31)
			{
				if (!mergeItemStack(movedStack, 31, 40, false))
				{
					return null;
				}
			}
			else if (fromId >= 31 && fromId < 40 && !mergeItemStack(movedStack, 4, 31, false))
			{
				return null;
			}
		}
		else if (!mergeItemStack(movedStack, 4, 40, false))
		{
			return null;
		}
		if (movedStack.getCount() == 0)
		{
			slot.putStack(null);
		}
		else
		{
			slot.onSlotChanged();
		}
		if (movedStack.getCount() == movedStackDupe.getCount())
		{
			return null;
		}
		slot.onTake(player, movedStack);
	}
	return movedStackDupe;
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:76,代码来源:ContainerSmelter.java

示例13: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
 * Take a stack from the specified inventory slot.
 */
@Nullable
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = (Slot)this.inventorySlots.get(index);

    if (slot != null && slot.getHasStack())
    {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();

        if (index < 27)
        {
            if (!this.mergeItemStack(itemstack1, 27, 63, true))
            {
                return ItemStack.EMPTY;
            }
        }
        else if (!this.mergeItemStack(itemstack1, 0, 27, false))
        {
            return ItemStack.EMPTY;
        }

        if (itemstack1.getCount() ==0)
        {
            slot.putStack(ItemStack.EMPTY);
        }
        else
        {
            slot.onSlotChanged();
        }

        if (itemstack1.getCount() ==itemstack.getCount())
        {
            return ItemStack.EMPTY;
        }

        slot.onTake(playerIn, itemstack1);
    }

    return itemstack;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:46,代码来源:ContainerRecover.java

示例14: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(index);

    if (slot != null && slot.getHasStack()) {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();

        if(index >= 0 && index < 36) {
            if(!itemstack1.isEmpty() && itemstack1.getItem() instanceof ItemBlueprint) {
                Slot sb = this.inventorySlots.get(this.slotBlueprint.slotNumber);
                if(!sb.getHasStack()) {
                    if(!this.mergeItemStack(itemstack1, sb.slotNumber, sb.slotNumber + 1, false)) {
                        return ItemStack.EMPTY;
                    }
                }
            }
        }

        if (index >= 0 && index < 27) {
            if (!this.mergeItemStack(itemstack1, 27, 36, false)) {
                return ItemStack.EMPTY;
            }
        } else if (index >= 27 && index < 36) {
            if (!this.mergeItemStack(itemstack1, 0, 27, false)) {
                return ItemStack.EMPTY;
            }
        } else if (!this.mergeItemStack(itemstack1, 0, 36, false)) {
            return ItemStack.EMPTY;
        }

        if (itemstack1.getCount() == 0) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }

        if (itemstack1.getCount() == itemstack.getCount()) {
            return ItemStack.EMPTY;
        }

        slot.onTake(playerIn, itemstack1);
    }

    return itemstack;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:48,代码来源:ContainerController.java

示例15: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
    ItemStack itemstack = ItemStack.EMPTY;
    Slot slot = this.inventorySlots.get(index);

    if (slot != null && slot.getHasStack()) {
        ItemStack itemstack1 = slot.getStack();
        itemstack = itemstack1.copy();

        if (index == 2) {
            if (!this.mergeItemStack(itemstack1, 3, 39, true)) {
                return ItemStack.EMPTY;
            }

            slot.onSlotChange(itemstack1, itemstack);
        } else if (index != 1 && index != 0) {
            if (CraftiniumSmeltRegistry.findMatching(itemstack1, playerIn.world, this.forge) != null) {
                if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
                    return ItemStack.EMPTY;
                }
            } else if (TileEntityFurnace.isItemFuel(itemstack1)) {
                if (!this.mergeItemStack(itemstack1, 1, 2, false)) {
                    return ItemStack.EMPTY;
                }
            } else if (index >= 3 && index < 30) {
                if (!this.mergeItemStack(itemstack1, 30, 39, false)) {
                    return ItemStack.EMPTY;
                }
            } else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) {
                return ItemStack.EMPTY;
            }
        } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) {
            return ItemStack.EMPTY;
        }

        if (itemstack1.isEmpty()) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }

        if (itemstack1.getCount() == itemstack.getCount()) {
            return ItemStack.EMPTY;
        }

        slot.onTake(playerIn, itemstack1);
    }

    return itemstack;
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:51,代码来源:CraftiniumForgeContainer.java


注:本文中的net.minecraft.inventory.Slot.onTake方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。