net.minecraft.inventory.Slot.onTake()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(170)

本文整理了Java中net.minecraft.inventory.Slot.onTake()方法的一些代码示例,展示了Slot.onTake()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Slot.onTake()方法的具体详情如下:
包路径:net.minecraft.inventory.Slot
类名称:Slot
方法名:onTake

Slot.onTake介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

@Nonnull
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
  ItemStack itemstack = ItemStack.EMPTY;
  Slot slot = inventorySlots.get(slotIndex);
  if(slot != null && slot.getHasStack()) {
    ItemStack itemstack1 = slot.getStack();
    itemstack = itemstack1.copy();
    if(slotIndex < 16) {
      if(!mergeItemStack(itemstack1, 16, 52, true))
        return ItemStack.EMPTY;
    } else {
      int i = itemstack.getItemDamage();
      if(i < 16) {
        Slot slot1 = inventorySlots.get(i);
        if(slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true))
          return ItemStack.EMPTY;
      }
    }
    if(itemstack1.isEmpty())
      slot.putStack(ItemStack.EMPTY);
    else slot.onSlotChanged();
    if(itemstack1.getCount() == itemstack.getCount())
      return ItemStack.EMPTY;
    slot.onTake(player, itemstack1);
  }
  return itemstack;
}

代码示例来源:origin: Vazkii/Quark

@Override
  public ItemStack onTake(EntityPlayer thePlayer, ItemStack stack) {
    finish(thePlayer, stack);
    return super.onTake(thePlayer, stack);
  }
});

代码示例来源:origin: Vazkii/Botania

@Nonnull
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
  ItemStack itemstack = ItemStack.EMPTY;
  Slot slot = inventorySlots.get(slotIndex);
  if(slot != null && slot.getHasStack()) {
    ItemStack itemstack1 = slot.getStack();
    itemstack = itemstack1.copy();
    int boxStart = 7;
    int boxEnd = boxStart + 24;
    int invEnd = boxEnd + 36;
    
    if(slotIndex < boxEnd) {
      if(!mergeItemStack(itemstack1, boxEnd, invEnd, true))
        return ItemStack.EMPTY;
    } else {
      if(!itemstack1.isEmpty() && (itemstack1.getItem() instanceof IBauble || itemstack1.getItem() instanceof IManaItem) && !mergeItemStack(itemstack1, boxStart, boxEnd, false))
        return ItemStack.EMPTY;
    }
    if(itemstack1.isEmpty())
      slot.putStack(ItemStack.EMPTY);
    else slot.onSlotChanged();
    if(itemstack1.getCount() == itemstack.getCount())
      return ItemStack.EMPTY;
    slot.onTake(player, itemstack1);
  }
  return itemstack;
}

代码示例来源:origin: Vazkii/Psi

@Nonnull
@Override
public ItemStack onTake(EntityPlayer playerIn, @Nonnull ItemStack stack) {
  super.onTake(playerIn, stack);
  assembler.onCraftCAD(stack);
  return stack;
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
  public ItemStack onTake(EntityPlayer player, ItemStack stack)
  {
    Triggers.trigger(Triggers.PLAYER_GOT_MAIL, player);
    return super.onTake(player, stack);
  }
});

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
  public ItemStack onTake(EntityPlayer player, ItemStack stack)
  {
    Triggers.trigger(Triggers.FREEZER_FREEZE, player);
    return super.onTake(player, stack);
  }
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

@Override
public ItemStack onTake(EntityPlayer playerIn, ItemStack stack) {
  this.onCrafting(stack);
  return super.onTake(playerIn, stack);
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
  public ItemStack onTake(EntityPlayer player, ItemStack stack)
  {
    Triggers.trigger(Triggers.OVEN_COOK, player);
    return super.onTake(player, stack);
  }
}

代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod

@Override
  public ItemStack onTake(EntityPlayer player, ItemStack stack)
  {
    Triggers.trigger(Triggers.PRINTER_COPY, player);
    return super.onTake(player, stack);
  }
}

代码示例来源:origin: jabelar/ExampleMod-1.12

@Override
public ItemStack onTake(EntityPlayer playerIn, ItemStack stack)
{
  this.onCrafting(stack);
  return super.onTake(playerIn, stack);
}

代码示例来源:origin: CyclopsMC/EvilCraft

@Override
public ItemStack onTake(EntityPlayer player, ItemStack itemStack) {
  if(!ItemStack.areItemStackTagsEqual(itemStack, this.getStack())) {
    tile.resetWork();
  }
  return super.onTake(player, itemStack);
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotClickedIndex) {
  @Nonnull ItemStack slotStackCopy = ItemStack.EMPTY;
  Slot theSlot = this.getSlot(slotClickedIndex);
  if (theSlot != null && theSlot.getHasStack()) {
    @Nonnull ItemStack slotStack = theSlot.getStack();
    slotStackCopy = slotStack.copy();
    if (slotStack.getCount() == 0) {
      theSlot.putStack(ItemStack.EMPTY);
    } else {
      theSlot.onSlotChanged();
    }
    if (slotStack.getCount() == slotStackCopy.getCount()) {
      return ItemStack.EMPTY;
    }
    theSlot.onTake(par1EntityPlayer, slotStack);
  }
  return slotStackCopy;
}

代码示例来源:origin: TheGreyGhost/MinecraftByExample

sourceSlot.onTake(player, sourceStack);  //onPickupFromSlot()
return copyOfSourceStack;

代码示例来源:origin: ForestryMC/ForestryMC

public static ItemStack transferStackInSlot(List<Slot> inventorySlots, EntityPlayer player, int slotIndex) {
  Slot slot = inventorySlots.get(slotIndex);
  if (slot == null || !slot.getHasStack()) {
    return ItemStack.EMPTY;
  }
  boolean fromCraftingSlot = slot instanceof SlotCrafting || slot instanceof SlotCrafter;
  int numSlots = inventorySlots.size();
  ItemStack stackInSlot = slot.getStack();
  ItemStack originalStack = stackInSlot.copy();
  if (!shiftItemStack(inventorySlots, stackInSlot, slotIndex, numSlots, fromCraftingSlot)) {
    return ItemStack.EMPTY;
  }
  slot.onSlotChange(stackInSlot, originalStack);
  if (stackInSlot.isEmpty()) {
    slot.putStack(ItemStack.EMPTY);
  } else {
    slot.onSlotChanged();
  }
  if (stackInSlot.getCount() == originalStack.getCount()) {
    return ItemStack.EMPTY;
  }
  slot.onTake(player, stackInSlot);
  return originalStack;
}

代码示例来源:origin: sinkillerj/ProjectE

return slot.onTake(player, newStack);

代码示例来源:origin: WayofTime/BloodMagic

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
  ItemStack stack = ItemStack.EMPTY;
  Slot slotObject = inventorySlots.get(slot);
  int slots = inventorySlots.size();
  if (slotObject != null && slotObject.getHasStack()) {
    ItemStack stackInSlot = slotObject.getStack();
    stack = stackInSlot.copy();
    if (stack.getItem() instanceof ItemTelepositionFocus) {
      if (slot <= slots) {
        if (!this.mergeItemStack(stackInSlot, 0, slots, false)) {
          return ItemStack.EMPTY;
        }
      } else if (!this.mergeItemStack(stackInSlot, slots, 36 + slots, false)) {
        return ItemStack.EMPTY;
      }
    }
    if (stackInSlot.getCount() == 0) {
      slotObject.putStack(ItemStack.EMPTY);
    } else {
      slotObject.onSlotChanged();
    }
    if (stackInSlot.getCount() == stack.getCount()) {
      return ItemStack.EMPTY;
    }
    slotObject.onTake(player, stackInSlot);
  }
  return stack;
}

代码示例来源:origin: SleepyTrousers/EnderIO

slot.onSlotChanged();
return slot.onTake(par1EntityPlayer, origStack);

代码示例来源:origin: sinkillerj/ProjectE

return slot.onTake(player, stack);

代码示例来源:origin: CoFH/CoFHCore

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
  if (!supportsShiftClick(player, slotIndex)) {
    return ItemStack.EMPTY;
  }
  ItemStack stack = ItemStack.EMPTY;
  Slot slot = inventorySlots.get(slotIndex);
  if (slot != null && slot.getHasStack()) {
    ItemStack stackInSlot = slot.getStack();
    stack = stackInSlot.copy();
    if (!performMerge(player, slotIndex, stackInSlot)) {
      return ItemStack.EMPTY;
    }
    slot.onSlotChange(stackInSlot, stack);
    if (stackInSlot.getCount() <= 0) {
      slot.putStack(ItemStack.EMPTY);
    } else {
      slot.putStack(stackInSlot);
    }
    if (stackInSlot.getCount() == stack.getCount()) {
      return ItemStack.EMPTY;
    }
    slot.onTake(player, stackInSlot);
  }
  return stack;
}

代码示例来源:origin: vadis365/TheErebus

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
  ItemStack stack = ItemStack.EMPTY;
  Slot slot = (Slot) inventorySlots.get(slotIndex);
  if (slot != null && slot.getHasStack()) {
    ItemStack stack1 = slot.getStack();
    stack = stack1.copy();
    if (slotIndex > 4) {
      if (stack1.getItem() == ModItems.MATERIALS && stack1.getItemDamage() != ItemMaterials.EnumErebusMaterialsType.SMOOTHIE_GLASS.ordinal() || stack1.getItem() != ModItems.MATERIALS) {
        if (!mergeItemStack(stack1, 0, 4, false))
          return ItemStack.EMPTY;
      } else if (stack1.getItem() == ModItems.MATERIALS && stack1.getItemDamage() == ItemMaterials.EnumErebusMaterialsType.SMOOTHIE_GLASS.ordinal())
        if (!mergeItemStack(stack1, 4, 5, false))
          return ItemStack.EMPTY;
    } else if (!mergeItemStack(stack1, 5, inventorySlots.size(), false))
      return ItemStack.EMPTY;
    if (stack1.getCount() == 0)
      slot.putStack(ItemStack.EMPTY);
    else
      slot.onSlotChanged();
    if (stack1.getCount() != stack.getCount())
      slot.onTake(player, stack1);
    else
      return ItemStack.EMPTY;
  }
  return stack;
}

相关文章