當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。