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


Java Slot.onSlotChanged方法代码示例

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


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

示例1: 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(!mergeItemStack(itemstack1, 0, 1, false)){
			return ItemStack.EMPTY;
		}
		if (itemstack1.isEmpty()) {
			slot.putStack(ItemStack.EMPTY);
		} else {
			slot.onSlotChanged();
		}
	}
	return itemstack;
}
 
开发者ID:tiffit,项目名称:Defier,代码行数:19,代码来源:CompressorContainer.java

示例2: transferStackInSlot

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

    ItemStack originalItem = slot.getStack();
    ItemStack copyItem = originalItem.copy();

    if(index >= 36) //Item is in our container, try placing in player's inventory.
    {
        if(!this.mergeItemStack(originalItem, 0, 36, true))
            return ItemStack.EMPTY;
    }
    else
    {
        if(!this.mergeItemStack(originalItem, 36, this.inventorySlots.size(), false))
            return ItemStack.EMPTY;
    }

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

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

    if(copyItem.getCount() == originalItem.getCount())
        return ItemStack.EMPTY;
    slot.onTake(player, copyItem);
    return originalItem;
}
 
开发者ID:Lumaceon,项目名称:CraftingParadiseMod,代码行数:37,代码来源:ContainerWorldMachine.java

示例3: 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

示例4: 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

示例5: 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 == 0) {
            if (!mergeItemStack(stackInSlot, 1, 36, false)) return ItemStack.EMPTY;
            srcSlot.onSlotChange(stackInSlot, stack);
        } else if (isProgrammableItem(stack)) {
            if (!mergeItemStack(stackInSlot, 0, 1, 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,代码行数:31,代码来源:ContainerProgrammer.java

示例6: 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,代码来源:ContainerBench.java

示例7: transferStackInSlot

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

	if (slot != null && slot.getHasStack()) {
		final ItemStack original = slot.getStack();
		copy = original.copy();

		if (slotIndex == 0) {
			if (!mergeItemStack(original, 5, 41, true)) return ItemStack.EMPTY;
			slot.onSlotChange(original, copy);
		} else if (slotIndex > 5) {
			if (original.getCount() == 1 && !mergeItemStack(original, 0, 5, false)) return ItemStack.EMPTY;
			slot.onSlotChange(original, copy);
		} else {
			if (!mergeItemStack(original, 5, 41, true)) return ItemStack.EMPTY;
			slot.onSlotChange(original, copy);
		}

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

		if (original.getCount() == copy.getCount()) return ItemStack.EMPTY;

		slot.onTake(player, original);
	}

	return copy;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:34,代码来源:ContainerOven.java

示例8: transferStackInSlot

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

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

        // Custom behaviour //
        if (fromSlot < 3)
        {
            // From TE Inventory to Player Inventory
            if (!this.mergeItemStack(current, startPlayerIndex, endPlayerIndex, true))
                return null;
        }
        else
        {
            // From Player Inventory to TE Inventory
            if (!this.mergeItemStack(current, startContainerIndex, endContainerIndex, false))
                return null;
        }
        // Custom behaviour //

        if (current.stackSize == 0)
            slot.putStack(null);
        else
            slot.onSlotChanged();

        if (current.stackSize == previous.stackSize)
            return null;
        slot.onPickupFromSlot(entityPlayer, current);
    }
    return previous;
}
 
开发者ID:koravel,项目名称:ElementalElaboration,代码行数:38,代码来源:BaseContainer.java

示例9: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
/**
 * Take a stack from the specified inventory slot.
 */
@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 < this.villagerInventory.getSizeInventory())
		{
			if (!this.mergeItemStack(itemstack1, this.villagerInventory.getSizeInventory(), this.inventorySlots.size(), true))
			{
				return ItemStack.EMPTY;
			}
		}
		else if (!this.mergeItemStack(itemstack1, 0, this.villagerInventory.getSizeInventory(), false))
		{
			return ItemStack.EMPTY;
		}

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

	return itemstack;
}
 
开发者ID:crazysnailboy,项目名称:VillagerInventory,代码行数:39,代码来源:ContainerVillagerInventory.java

示例10: transferStackInSlot

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

    // Assume inventory and hotbar slot IDs are contiguous
    int inventoryStart = playerSlots.get(0).slotNumber;
    int hotbarStart = hotbarSlots.get(0).slotNumber;
    int hotbarEnd = hotbarSlots.get(hotbarSlots.size() - 1).slotNumber + 1;

    if (slot != null && slot.getHasStack()) {
        @Nonnull ItemStack slotStack = slot.getStack();
        itemStack = slotStack.copy();

        // Try merge output into inventory and signal change
        if (slotIndex == outputSlot.slotNumber) {
            if (!mergeItemStack(slotStack, inventoryStart, hotbarEnd, true))
                return ItemStack.EMPTY;

            slot.onSlotChange(slotStack, itemStack);
        }

        // Try merge stacks within inventory and hotbar spaces
        else if (slotIndex >= inventoryStart && slotIndex < hotbarEnd) {
            boolean merged = false;
            if (TileBloomeryFurnace.isItemFuel(slotStack))
                merged = mergeItemStack(slotStack, fuelSlot.slotNumber, fuelSlot.slotNumber + 1, false);
            else if (TileBloomeryFurnace.isItemPrimaryInput(slotStack))
                merged = mergeItemStack(slotStack, primarySlot.slotNumber, primarySlot.slotNumber + 1, false);
            else if (TileBloomeryFurnace.isItemSecondaryInput(slotStack))
                merged = mergeItemStack(slotStack, secondarySlot.slotNumber, secondarySlot.slotNumber + 1, false);

            if (!merged) {
                if (slotIndex >= inventoryStart && slotIndex < hotbarStart) {
                    if (!mergeItemStack(slotStack, hotbarStart, hotbarEnd, false))
                        return ItemStack.EMPTY;
                } else if (slotIndex >= hotbarStart && slotIndex < hotbarEnd && !this.mergeItemStack(slotStack, inventoryStart, hotbarStart, false))
                    return ItemStack.EMPTY;
            }
        }

        // Try merge stack into inventory
        else if (!mergeItemStack(slotStack, inventoryStart, hotbarEnd, false))
            return ItemStack.EMPTY;

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

        if (slotStack.getCount() == itemStack.getCount())
            return ItemStack.EMPTY;

        slot.onTake(player, slotStack);
    }

    return itemStack;
}
 
开发者ID:jaquadro,项目名称:GardenStuff,代码行数:60,代码来源:ContainerBloomeryFurnace.java

示例11: transferStackInSlot

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

        if (slot == null || !slot.getHasStack())
        {
            return null;
        }

        ItemStack newStack = slot.getStack(), oldStack = newStack.copy();
        boolean isMerged = false;
        
        if (index >= 0 && index <= 2)
        {
            isMerged = mergeItemStack(newStack, 3, 39, true);
        }else if (index >= 3 && index < 30)
        {
            isMerged = ! betterySlot.getHasStack() && newStack.stackSize <= 1 && mergeItemStack(newStack, 0, 1, false)
                    || !filmSlot.getHasStack() && mergeItemStack(newStack, 1, 2, false)
                    || mergeItemStack(newStack, 30, 39, false);
        }else if (index >= 30 && index < 39)
        {
            isMerged = !betterySlot.getHasStack()&& newStack.stackSize <= 1&& mergeItemStack(newStack, 0, 1, false)
                    || !filmSlot.getHasStack() && mergeItemStack(newStack, 1, 2, false)
                    || mergeItemStack(newStack, 3, 30, false);
        }
        
        if (!isMerged)
        {
            return null;
        }

        if (newStack.stackSize == 0)
        {
            slot.putStack(null);
        }
        else
        {
            slot.onSlotChanged();
        }
        slot.onPickupFromSlot(playerIn, newStack);
        return oldStack;
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:44,代码来源:ContainerCamera.java

示例12: 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 == 2)
		{
			if (!mergeItemStack(itemstack1, 3, 39, true))
			{
				return null;
			}
			slot.onSlotChange(itemstack1, itemstack);
		}
		else if (par2 != 1 && par2 != 0)
		{
			if (KilnRecipeHandler.instance().getSmeltingResult(itemstack1) != null)
			{
				if (!mergeItemStack(itemstack1, 0, 1, false))
				{
					return null;
				}
			}
			else if (FuelRegistry.getBurnTime(FuelConsumerType.KILN, itemstack1) > 0)
			{
				if (!mergeItemStack(itemstack1, 1, 2, false))
				{
					return null;
				}
			}
			else if (par2 >= 3 && par2 < 30)
			{
				if (!mergeItemStack(itemstack1, 30, 39, false))
				{
					return null;
				}
			}
			else if (par2 >= 30 && par2 < 39 && !mergeItemStack(itemstack1, 3, 30, false))
			{
				return null;
			}
		}
		else if (!mergeItemStack(itemstack1, 3, 39, false))
		{
			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,代码来源:ContainerObsidianKiln.java

示例13: 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();

        boolean changed = false;
        if (index >= 0 && index < 36) {
            if(this.mergeItemStack(itemstack1, 36, inventorySlots.size(), false)) {
                changed = true;
            }
        }

        if(!changed) {
            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,代码行数:46,代码来源:ContainerItemBus.java

示例14: 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

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