本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}