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


Java Slot.getHasStack方法代码示例

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


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

示例1: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
public ItemStack transferStackInSlot(EntityPlayer ply, int prevSlot) {
	ItemStack itemstack = ItemStack.EMPTY;
	Slot slot = inventorySlots.get(prevSlot);
	if (slot != null && slot.getHasStack()) {
		ItemStack itemstack1 = slot.getStack();
		itemstack = itemstack1.copy();
		if (prevSlot < size) {
			if (!mergeItemStack(itemstack1, size, inventorySlots.size(), true)) {
				return ItemStack.EMPTY;
			}
		} else if (!mergeItemStack(itemstack1, 0, size, false)) {
			return ItemStack.EMPTY;
		}
		if (itemstack1.isEmpty()) {
			slot.putStack(ItemStack.EMPTY);
		} else {
			slot.onSlotChanged();
		}
	}
	return itemstack;
}
 
开发者ID:cjburkey01,项目名称:MiningWells,代码行数:22,代码来源:ContainerUpgradeStation.java

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

示例3: transferStackInSlot

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

        if (slot != null && slot.getHasStack())
        {
            slot.putStack((ItemStack)null);
        }
    }

    return null;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:GuiContainerCreative.java

示例4: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
    if (index >= this.inventorySlots.size() - 9 && index < this.inventorySlots.size())
    {
        Slot slot = (Slot)this.inventorySlots.get(index);

        if (slot != null && slot.getHasStack())
        {
            slot.putStack((ItemStack)null);
        }
    }

    return null;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:15,代码来源:GuiContainerCreative.java

示例5: 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 < beltSlots)
        {
            if (!this.mergeItemStack(itemstack1, beltSlots, this.inventorySlots.size(), true))
            {
                return ItemStack.EMPTY;
            }
        }
        else if (!this.mergeItemStack(itemstack1, 0, beltSlots, false))
        {
            return ItemStack.EMPTY;
        }

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

    return itemstack;
}
 
开发者ID:gigaherz,项目名称:ToolBelt,代码行数:36,代码来源:ContainerBelt.java

示例6: moveStackToInventory

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
protected boolean moveStackToInventory(ItemStack itemStackIn) {
	for (int i = 0; i <= 36; i++) {
		Slot possiblyOpenSlot = inventorySlots.get(i);
		if (!possiblyOpenSlot.getHasStack()) {
			possiblyOpenSlot.putStack(itemStackIn);
			return true;
		}
	}
	return false;
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:11,代码来源:ContainerDankNull.java

示例7: renameItem

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
private void renameItem()
{
    String s = this.nameField.getText();
    Slot slot = this.anvil.getSlot(0);

    if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
    {
        s = "";
    }

    this.anvil.updateItemName(s);
    this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s)));
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:14,代码来源:GuiRepair.java

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

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

示例10: transferStackInSlot

import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, 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 == 0){
			// ent -> player
			if(!this.mergeItemStack(current, 13, 49, true))
				return null;
		}
		else if(fromSlot >= 13) {
			// player -> ent
			if(!this.mergeItemStack(current, 0, 1, false))
				return null;
		}
	// end custom behaviour

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

		if (current.stackSize == previous.stackSize)
			return null;
		slot.onPickupFromSlot(playerIn, current);
	}
	
	return previous;
}
 
开发者ID:ImagicTheCat,项目名称:FundamentalChemistry,代码行数:35,代码来源:TileSimpleMachineContainer.java

示例11: transferStackInSlot

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

	if (slot != null && slot.getHasStack())
	{
		ItemStack slotStack = slot.getStack();

		if (index < TileEntityChunkLoader.INV_SLOTS)
		{
			if (!this.mergeItemStack(slotStack, TileEntityChunkLoader.INV_SLOTS, inventorySlots.size(), true))
			{
				return new ItemStack(Items.ENDER_PEARL, 0);
			}
		}
		else if (!this.mergeItemStack(slotStack, 0, TileEntityChunkLoader.INV_SLOTS, false))
		{
			return ItemStack.EMPTY;
		}

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

	return stack;
}
 
开发者ID:DarkMorford,项目名称:Simple-Chunks,代码行数:35,代码来源:ContainerChunkLoader.java

示例12: 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 < 3) {
            if (!this.mergeItemStack(itemstack1, 3, this.inventorySlots.size(), true)) {
            	te.updateResult();
                return ItemStack.EMPTY;
            }
        } else if (!this.mergeItemStack(itemstack1, 0, 3, false)) {
        	te.updateResult();
            return ItemStack.EMPTY;
        }

        if (itemstack1.isEmpty()) {
            slot.putStack(ItemStack.EMPTY);
        } else {
            slot.onSlotChanged();
        }
    }
    te.updateResult();
    return itemstack;
}
 
开发者ID:tiffit,项目名称:Defier,代码行数:29,代码来源:PatternMolderContainer.java

示例13: 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, 19, 55, true)) return ItemStack.EMPTY;
			slot.onSlotChange(original, copy);
		} else if (slotIndex > 19) {
			if (original.getCount() == 1 && !mergeItemStack(original, 0, 1, false)) return ItemStack.EMPTY;
			slot.onSlotChange(original, copy);
		} else {
			if (!mergeItemStack(original, 19, 55, 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,代码来源:ContainerApiary.java

示例14: transferStackInSlot

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

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

		if(slotNumber == 0) {
			if(!this.mergeItemStack(slotStack, 5, 41, true)) {
				return null;
			}

			slot.onSlotChange(slotStack, itemstack);
		} else if(!this.mergeItemStack(slotStack, 5, 41, false)) {
			return null;
		}

		if(slotStack.stackSize == 0) {
			slot.putStack((ItemStack) null);
		} else {
			slot.onSlotChanged();
		}

		if(slotStack.stackSize == itemstack.stackSize) {
			return null;
		}

		slot.onPickupFromSlot(player, slotStack);
	}

	return itemstack;
}
 
开发者ID:viddeno,项目名称:Technical,代码行数:34,代码来源:ContainerMachineMiner.java

示例15: 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();
		EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(itemstack);

		if (index >= 0 && index < 4) {
			if (!this.mergeItemStack(itemstack1, 8, 44, false))
				return ItemStack.EMPTY;
		} else if (index >= 4 && index < 7) {
			if (!this.mergeItemStack(itemstack1, 8, 44, false))
				return ItemStack.EMPTY;
		} else if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR
				&& !this.inventorySlots.get(4 - entityequipmentslot.getIndex()).getHasStack()) {
			int i = 4 - entityequipmentslot.getIndex();

			if (!this.mergeItemStack(itemstack1, i, i + 1, false))
				return ItemStack.EMPTY;
		} else if (entityequipmentslot == EntityEquipmentSlot.OFFHAND
				&& !this.inventorySlots.get(44).getHasStack()) {
			if (!this.mergeItemStack(itemstack1, 44, 45, false))
				return ItemStack.EMPTY;
		} else if (itemstack1.getItem() instanceof ItemAmmoBelt
				&& !this.inventorySlots.get(7).getHasStack()) {
			if (!this.mergeItemStack(itemstack1, 7, 8, false))
				return ItemStack.EMPTY;
		} else if (itemstack1.getItem() instanceof ItemWearable && index >= 8) {
			if (!this.mergeItemStack(itemstack1, 4, 7, false))
				return ItemStack.EMPTY;
		} else if (itemstack1.getItem() instanceof ItemAmmo && ammoBelt && index < 44) {
			if (!this.mergeItemStack(itemstack1, 45, 54, false))
				return ItemStack.EMPTY;
		} else if (index >= 8 && index < 35) {
			if (!this.mergeItemStack(itemstack1, 35, 44, false))
				return ItemStack.EMPTY;
		} else if (index >= 35 && index < 44) {
			if (!this.mergeItemStack(itemstack1, 8, 35, false))
				return ItemStack.EMPTY;
		} else if (!this.mergeItemStack(itemstack1, 8, 44, 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,代码行数:63,代码来源:ContainerWearables.java


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