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


Java Slot.onPickupFromSlot方法代码示例

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


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

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

        if (fromSlot < 9) {
            // From TE Inventory to Player Inventory
            if (!this.mergeItemStack(current, 9, 45, true))
                return null;
        } else {
            // From Player Inventory to TE Inventory
            if (!this.mergeItemStack(current, 0, 9, false))
                return null;
        }

        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:astronautlabs,项目名称:rezolve,代码行数:31,代码来源:ContainerBase.java

示例2: transferStackInSlot

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

	ItemStack newStack = slot.getStack(), oldStack = newStack.copy();
	boolean isMerged = false;

	if (index >= 0 && index <= 1) {
		isMerged = mergeItemStack(newStack, 2, 38, true);
	} else if (index >= 2 && index < 29) {
		isMerged = !pictureInSlot.getHasStack() && newStack.stackSize <= 1 && mergeItemStack(newStack, 0, 1, false)
				|| mergeItemStack(newStack, 29, 38, false);
	} else if (index >= 29 && index < 38) {
		isMerged = !pictureInSlot.getHasStack() && newStack.stackSize <= 1 && mergeItemStack(newStack, 0, 1, false)
				|| mergeItemStack(newStack, 2, 29, false);
	}

	if (!isMerged) {
		return null;
	}

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

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

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

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

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

示例7: 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 <= 4)
        {
            isMerged = mergeItemStack(newStack, 5, 41, true);
        }else if (index >= 5 && index < 32)
        {
            isMerged = AllSlot.getStackInSlot(0)==null && newStack.stackSize <= 10 && mergeItemStack(newStack, 0, 1, false)
                    || AllSlot.getStackInSlot(1)==null && newStack.stackSize <= 10 && mergeItemStack(newStack, 1, 2, false)
                    || AllSlot.getStackInSlot(2)==null && newStack.stackSize <= 1 && mergeItemStack(newStack, 2, 3, false)
                    || mergeItemStack(newStack, 3, 4, false)
                    || mergeItemStack(newStack, 32, 41, false);
        }else if (index >= 32 && index < 41)
        {
        	isMerged = AllSlot.getStackInSlot(0)==null && newStack.stackSize <= 10 && mergeItemStack(newStack, 0, 1, false)
                    || AllSlot.getStackInSlot(1)==null && newStack.stackSize <= 10 && mergeItemStack(newStack, 1, 2, false)
                    || AllSlot.getStackInSlot(2)==null && newStack.stackSize <= 1 && mergeItemStack(newStack, 2, 3, false)
                    || mergeItemStack(newStack, 3, 4, false)
                    || mergeItemStack(newStack, 5, 32, false);
        }
        
        if (!isMerged)
        {
            return null;
        }

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

示例8: transferStackInSlot

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

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

		if ((slotIndex < 0 || slotIndex > 2) && slotIndex != 3) {
			if (!ingredientSlot.getHasStack() && ingredientSlot.isItemValid(itemstack1)) {
				if (!mergeItemStack(itemstack1, 3, 4, false))
					return null;
			} else if (PotionSlot.canHoldPotion(itemstack)) {
				if (!mergeItemStack(itemstack1, 0, 3, false))
					return null;
			} else if (slotIndex >= 4 && slotIndex < 31) {
				if (!mergeItemStack(itemstack1, 31, 40, false))
					return null;
			} else if (slotIndex >= 31 && slotIndex < 40) {
				if (!mergeItemStack(itemstack1, 4, 31, false))
					return null;
			} else if (!mergeItemStack(itemstack1, 4, 40, false))
				return null;
		} else {
			if (!mergeItemStack(itemstack1, 4, 40, true))
				return null;

			slot.onSlotChange(itemstack1, itemstack);
		}

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

		if (itemstack1.stackSize == itemstack.stackSize)
			return null;

		slot.onPickupFromSlot(player, itemstack1);
	}

	return itemstack;
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:45,代码来源:ContainerNewBrewingStand.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 var3 = null;
	Slot var4 = (Slot) inventorySlots.get(index);

	if (var4 != null && var4.getHasStack()) {
		ItemStack var5 = var4.getStack();
		var3 = var5.copy();

		if (index == 0) {
			if (!mergeItemStack(var5, 2, 38, true))
				return null;
		} else if (index == 1) {
			if (!mergeItemStack(var5, 2, 38, true))
				return null;
		} else if (var5.getItem() == Items.dye && var5.getItemDamage() == 4) {
			if (!mergeItemStack(var5, 1, 2, true))
				return null;
		} else {
			if (((Slot) inventorySlots.get(0)).getHasStack() || !((Slot) inventorySlots.get(0)).isItemValid(var5))
				return null;

			if (var5.hasTagCompound() && var5.stackSize == 1) {
				((Slot) inventorySlots.get(0)).putStack(var5.copy());
				var5.stackSize = 0;
			} else if (var5.stackSize >= 1) {
				((Slot) inventorySlots.get(0)).putStack(new ItemStack(var5.getItem(), 1, var5.getItemDamage()));
				--var5.stackSize;
			}
		}

		if (var5.stackSize == 0)
			var4.putStack((ItemStack) null);
		else
			var4.onSlotChanged();

		if (var5.stackSize == var3.stackSize)
			return null;

		var4.onPickupFromSlot(playerIn, var5);
	}

	return var3;
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:48,代码来源:ContainerEnchantment.java

示例10: 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 || slotNumber == 1) {
			if(!this.mergeItemStack(slotStack, 4, 40, true)) {
				return null;
			}

			slot.onSlotChange(slotStack, itemstack);
		} else if(slotNumber != 0 && slotNumber != 1 && slotNumber != 2 && slotNumber != 3) {
			if(this.tileEntity.isItemValidForSlot(0, itemstack)) {
				if(!this.mergeItemStack(slotStack, 0, 1, false)) {
					return null;
				}
			} else if(this.tileEntity.isItemValidForSlot(1, itemstack)) {
				if(!this.mergeItemStack(slotStack, 1, 2, false)) {
					return null;
				}
			} else if(TileEntityMachineRepairingForge.isItemFuelBurning(slotStack)) {
				if(!this.mergeItemStack(slotStack, 2, 3, false)) {
					return null;
				}
			} else if(TileEntityMachineRepairingForge.isItemFuelElectrical(slotStack)) {
				if(!this.mergeItemStack(slotStack, 3, 4, false)) {
					return null;
				}
			} else if(slotNumber >= 4 && slotNumber < 31) {
				if(!this.mergeItemStack(slotStack, 30, 39, false)) {
					return null;
				}
			} else if(slotNumber >= 30 && slotNumber < 39 && !this.mergeItemStack(slotStack, 4, 30, false)) {
				return null;
			}
		} else if(!this.mergeItemStack(slotStack, 3, 39, false)) {
			return null;
		} else {
			slotStack.stackSize = slotStack.stackSize * 2;
		}

		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,代码行数:60,代码来源:ContainerMachineRepairingForge.java

示例11: 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 == 5 || slotNumber == 6 || slotNumber == 7 || slotNumber == 8 || slotNumber == 9 || slotNumber == 10) {
			if(!this.mergeItemStack(slotStack, 11, 47, true)) {
				return null;
			}

			slot.onSlotChange(slotStack, itemstack);
		} else if(slotNumber != 0 && slotNumber != 1 && slotNumber != 2 && slotNumber != 3 && slotNumber != 4) {
			if(this.tileEntity.isItemUsedInRecipe(slotStack)) {
				if(!this.mergeItemStack(slotStack, 0, 3, false)) {
					return null;
				}
			} else if(TileEntityMachineRepairingForge.isItemFuelBurning(slotStack)) {
				if(!this.mergeItemStack(slotStack, 4, 5, false)) {
					return null;
				}
			} else if(TileEntityMachineRepairingForge.isItemFuelElectrical(slotStack)) {
				if(!this.mergeItemStack(slotStack, 3, 4, false)) {
					return null;
				}
			} else if(slotNumber >= 11 && slotNumber < 38) {
				if(!this.mergeItemStack(slotStack, 0, 2, false)) {
					return null;
				}
			} else if(slotNumber >= 38 && slotNumber < 47 && !this.mergeItemStack(slotStack, 0, 2, false)) {
				return null;
			}
		} else if(!this.mergeItemStack(slotStack, 11, 47, 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,代码行数:54,代码来源:ContainerMachine.java

示例12: 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 || slotNumber == 1) {
			if(!this.mergeItemStack(slotStack, 4, 40, true)) {
				return null;
			}

			slot.onSlotChange(slotStack, itemstack);
		} else if(slotNumber != 0 && slotNumber != 1 && slotNumber != 2 && slotNumber != 3) {
			if(this.tileEntity.isItemValidForSlot(0, itemstack)) {
				if(!this.mergeItemStack(slotStack, 0, 1, false)) {
					return null;
				}
			} else if(this.tileEntity.isItemValidForSlot(1, itemstack)) {
				if(!this.mergeItemStack(slotStack, 1, 2, false)) {
					return null;
				}
			} else if(TileEntityPump.isItemFuelBurning(slotStack)) {
				if(!this.mergeItemStack(slotStack, 2, 3, false)) {
					return null;
				}
			} else if(TileEntityPump.isItemFuelElectrical(slotStack)) {
				if(!this.mergeItemStack(slotStack, 3, 4, false)) {
					return null;
				}
			} else if(slotNumber >= 4 && slotNumber < 31) {
				if(!this.mergeItemStack(slotStack, 30, 39, false)) {
					return null;
				}
			} else if(slotNumber >= 30 && slotNumber < 39 && !this.mergeItemStack(slotStack, 4, 30, false)) {
				return null;
			}
		} else if(!this.mergeItemStack(slotStack, 3, 39, false)) {
			return null;
		} else {
			slotStack.stackSize = slotStack.stackSize * 2;
		}

		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,代码行数:60,代码来源:ContainerPump.java

示例13: transferStackInSlot

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

	// 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;

	// null checks and checks if the item can be stacked (maxStackSize > 1)
	if (slotObject != null && slotObject.getHasStack()) {
		ItemStack stackInSlot = slotObject.getStack();
		stack = stackInSlot.copy();

		if (slot >= inventoryStart && slot < hotbarEnd) {
			// If the item is a 'special' item, try putting it into its
			// special slot
			boolean handledSpecialItem = false;
			for (Slot ss : specialSlots) {
				if (!tileEntity.isItemValidForSlot(ss.getSlotIndex(), stackInSlot))
					continue;
				handledSpecialItem = mergeItemStack(stackInSlot, ss.slotNumber, ss.slotNumber + 1, false);
				if (handledSpecialItem)
					break;
			}

			// Else treat it like any normal item
			if (!handledSpecialItem) {
				if (slot >= inventoryStart && slot < hotbarStart) {
					if (!mergeItemStack(stackInSlot, hotbarStart, hotbarEnd, false))
						return null;
				} else if (slot >= hotbarStart && slot < hotbarEnd && !this.mergeItemStack(stackInSlot, inventoryStart, hotbarStart, false))
					return null;
			}
		}
		// Try merge stack into inventory
		else if (!mergeItemStack(stackInSlot, inventoryStart, hotbarEnd, false))
			return null;

		if (stackInSlot.stackSize == 0) {
			slotObject.putStack(null);
		} else {
			slotObject.onSlotChanged();
		}

		if (stackInSlot.stackSize == stack.stackSize) {
			return null;
		}
		slotObject.onPickupFromSlot(player, stackInSlot);
	}
	return stack;
}
 
开发者ID:PC-Logix,项目名称:OpenSensors,代码行数:54,代码来源:SensorContainer.java


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