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

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

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

Slot.getStack介绍

暂无

代码示例

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

private static ItemStack getStackUnderMouse() {
    GuiScreen screen = Minecraft.getMinecraft().currentScreen;
    if(screen instanceof GuiContainer) {
      Slot slotUnderMouse = ((GuiContainer) screen).getSlotUnderMouse();
      if(slotUnderMouse != null)
        return slotUnderMouse.getStack();
    }
    return jeiPanelSupplier.get();
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
public void onSlotChange( final Slot s )
{
  if( s == this.patternSlotOUT && Platform.isServer() )
  {
    for( final IContainerListener listener : this.listeners )
    {
      for( final Slot slot : this.inventorySlots )
      {
        if( slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix )
        {
          listener.sendSlotContents( this, slot.slotNumber, slot.getStack() );
        }
      }
      if( listener instanceof EntityPlayerMP )
      {
        ( (EntityPlayerMP) listener ).isChangingQuantityOnly = false;
      }
    }
    this.detectAndSendChanges();
  }
  if( s == this.craftSlot && Platform.isClient() )
  {
    this.getAndUpdateOutput();
  }
}

代码示例来源: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/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: SleepyTrousers/EnderIO

private static int getSlotStackSize(@Nonnull Slot slot) {
 ItemStack stack = slot.getStack();
 return stack.getCount();
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

if( s == this.top )
  otherSlot = this.bottom.getStack();
  otherSlot = this.top.getStack();

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

private void findCandidates(@Nonnull Candidate candidates, @Nonnull ItemStack stack, @Nonnull Collection<Slot> slots) {
 for (Slot slot : slots) {
  ItemStack slotStack = slot.getStack();
  if (ItemUtil.areStackMergable(slotStack, stack)) {
   candidates.sourceSlots.add(slot);
   candidates.available += slotStack.getCount();
  }
 }
}

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

@Override
public ItemStack getSpecimen(int index) {
  Slot slot = container.getForestrySlot(getSelectedSlot(index));
  return slot.getStack();
}

代码示例来源:origin: mezz/JustEnoughItems

@Nullable
private <T> IClickedIngredient<T> createClickedIngredient(@Nullable T ingredient, GuiContainer guiContainer) {
  if (ingredient != null && ingredientRegistry.isValidIngredient(ingredient)) {
    Rectangle area = null;
    Slot slotUnderMouse = guiContainer.getSlotUnderMouse();
    if (ingredient instanceof ItemStack && slotUnderMouse != null && ItemStack.areItemStacksEqual(slotUnderMouse.getStack(), (ItemStack) ingredient)) {
      area = new Rectangle(slotUnderMouse.xPos, slotUnderMouse.yPos, 16, 16);
    }
    return ClickedIngredient.create(ingredient, area);
  }
  return null;
}

代码示例来源:origin: ExtraCells/ExtraCells2

@Override
public void onContainerClosed(EntityPlayer entityPlayer) {
  super.onContainerClosed(entityPlayer);
  if (!entityPlayer.world.isRemote) {
    this.monitor.removeListener(this);
    for (int i = 0; i < 2; i++) {
      this.player.dropItem(this.inventorySlots.get(i).getStack(), false);
    }
  }
}

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

@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
  ItemStack itemstack = ItemStack.EMPTY;
  Slot slot = inventorySlots.get(index);
  if(index >= 9 && index < 36 && slot != null && slot.getHasStack()) {
    ItemStack stack = slot.getStack();
    if(!mergeItemStack(stack, 46, 72, false))
      return ItemStack.EMPTY;
  }
  
  return super.transferStackInSlot(playerIn, index);
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

if( slot != null )
  this.dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : ItemStack.EMPTY;

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

final ItemStack isA = a.getStack();
final ItemStack isB = b.getStack();

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

public boolean isEqual(List<Slot> craftingGrid) {
 for (int slotIdx = 0; slotIdx < 9; slotIdx++) {
  ItemStack a = slots.get(slotIdx);
  ItemStack b = craftingGrid.get(slotIdx).getStack();
  if ((!a.isEmpty() || !b.isEmpty()) && !ItemUtil.areStacksEqual(a, b)) {
   return false;
  }
 }
 return true;
}

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

private void sendReturnAreaSlots() {
 for (int slotIdx = firstSlotReturn; slotIdx < endSlotReturn; slotIdx++) {
  ItemStack stack = inventorySlots.get(slotIdx).getStack();
  if (!stack.isEmpty()) {
   stack = stack.copy();
  }
  inventoryItemStacks.set(slotIdx, stack);
  for (IContainerListener crafter : this.listeners) {
   crafter.sendSlotContents(this, slotIdx, stack);
  }
 }
}

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

private boolean updateAndCheckCraftStackOrLessInTotal() {
  ItemStack craftedStack = getSlot(CRAFTING_SLOT).getStack();
  currentCraftTotalSize += craftedStack.getCount();
  return currentCraftTotalSize <= craftedStack.getMaxStackSize();
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

final ItemStack t = d.getStack().copy();
final ItemStack t = d.getStack().copy();

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

@Override
public IMessage doOpenFilterGui(int filterIndex) {
 TileVacuumChest te = getTileEntity();
 if (te != null) {
  if (filterIndex == FilterGuiUtil.INDEX_NONE) {
   te.getItemFilter().openGui(player, filterSlot.getStack(), te.getWorld(), te.getPos());
  }
 }
 return null;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

final ItemStack is = s.getStack();
if( s instanceof AppEngSlot && ( ( (AppEngSlot) s ).renderIconWithItem() || is.isEmpty() ) && ( ( (AppEngSlot) s ).shouldDisplay() ) )

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

case SPLIT_OR_PLACE_SINGLE:
  ItemStack is = s.getStack();
  if( !is.isEmpty() )

相关文章