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

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

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

Slot.isItemValid介绍

暂无

代码示例

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

@Override
public boolean isItemValid(ItemStack stack)
{
  return super.isItemValid(stack);
}
@Override

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
public boolean isItemValid(@Nullable ItemStack stack) {
 return super.isItemValid(stack);
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
public boolean isItemValid(@Nullable ItemStack stack) {
 return super.isItemValid(stack);
}

代码示例来源:origin: Mine-and-blade-admin/Battlegear2

@Override
  public boolean isItemValid(ItemStack stack) {
    if (stack == null || stack.getItem() instanceof IHeraldryItem){
      return super.isItemValid(stack);
    }
    return false;
  }
}

代码示例来源:origin: SonarSonic/Calculator

@Override
public boolean isItemValid(ItemStack stack) {
  if (type == null) {
    return super.isItemValid(stack);
  }
  return !stack.isEmpty() && stack.getItem() != type;
}

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

@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
  Slot containerSlot = getSlot(slot);
  if(containerSlot == null || !containerSlot.isItemValid(stack))
    return stack;
  
  return super.insertItem(slot, stack, simulate);
}

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

if( !isB.isEmpty() && !a.isItemValid( isB ) )
if( !isA.isEmpty() && !b.isItemValid( isA ) )

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

if( d.isItemValid( tis ) )
if( d.isItemValid( tis ) )

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

@Override
  public boolean isItemValid(ItemStack stack) {
    return super.isItemValid(stack) && !stack.isEmpty() && stack.getItem() != null && stack.getItem() instanceof ItemDragonArmor && stack.getMetadata() == 2;
  }
});

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

@Override
  public boolean isItemValid(ItemStack stack) {
    return super.isItemValid(stack) && !stack.isEmpty() && stack.getItem() != null && stack.getItem() instanceof ItemDragonArmor && stack.getMetadata() == 1;
  }
});

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

@Override
  public boolean isItemValid(ItemStack stack) {
    return super.isItemValid(stack) && !stack.isEmpty() && stack.getItem() != null && stack.getItem() instanceof ItemDragonArmor && stack.getMetadata() == 3;
  }
});

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

@Override
  public boolean isItemValid(ItemStack stack) {
    return super.isItemValid(stack) && !stack.isEmpty() && stack.getItem() != null && stack.getItem() instanceof ItemDragonArmor && stack.getMetadata() == 0;
  }
});

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

private static boolean shiftToMachineInventory(List<Slot> inventorySlots, ItemStack stackToShift, int numSlots, boolean mergeOnly) {
    for (int machineIndex = playerInventorySize; machineIndex < numSlots; machineIndex++) {
      Slot slot = inventorySlots.get(machineIndex);
      if (mergeOnly && slot.getStack().isEmpty()) {
        continue;
      }
      if (slot instanceof SlotForestry) {
        SlotForestry slotForestry = (SlotForestry) slot;
        if (!slotForestry.canShift() || slotForestry.isPhantom()) {
          continue;
        }
      }
      if (!slot.isItemValid(stackToShift)) {
        continue;
      }
      if (shiftItemStackToRange(inventorySlots, stackToShift, machineIndex, 1)) {
        return true;
      }
    }
    return false;
  }
}

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

boolean isValid = s.isItemValid(
    is ) || s instanceof SlotOutput || s instanceof AppEngCraftingSlot || s instanceof SlotDisabled || s instanceof SlotInaccessible || s instanceof SlotFake || s instanceof SlotRestrictedInput || s instanceof SlotDisconnected;
if( isValid && s instanceof SlotRestrictedInput )

代码示例来源:origin: Mine-and-blade-admin/Battlegear2

@Override
  public boolean isItemValid(ItemStack par1ItemStack) {
    if (par1ItemStack.isEmpty()) {
      return super.isItemValid(ItemStack.EMPTY);
    } else if(inventory instanceof InventoryPlayer){
      if(super.isItemValid(par1ItemStack)) {
        EntityPlayer player = ((InventoryPlayer) inventory).player;
        final boolean inBattle = BattlegearUtils.isPlayerInBattlemode(player);
        if(!inBattle){
          ((InventoryPlayer) inventory).currentItem += InventoryPlayerBattle.OFFSET;
        }
        boolean result;
        if (mainHand) {
          result = BattlegearUtils.isMainHand(par1ItemStack, partner.getStack(), player) && BattlegearUtils.isOffHand(partner.getStack(), par1ItemStack, player);
        } else {
          result = BattlegearUtils.isOffHand(par1ItemStack, partner.getStack() ,player) && BattlegearUtils.isMainHand(partner.getStack(), par1ItemStack, player);
        }
        if(!inBattle){
          ((InventoryPlayer) inventory).currentItem -= InventoryPlayerBattle.OFFSET;
        }
        return result;
      }
    }
    return false;
  }
}

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

@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 < this.dragonInv.getSizeInventory()) {
      if (!this.mergeItemStack(itemstack1, this.dragonInv.getSizeInventory(), this.inventorySlots.size(), true)) {
        return ItemStack.EMPTY;
      }
    } else if (this.getSlot(1).isItemValid(itemstack1) && !this.getSlot(1).getHasStack()) {
      if (!this.mergeItemStack(itemstack1, 1, 2, false)) {
        return ItemStack.EMPTY;
      }
    } else if (this.getSlot(0).isItemValid(itemstack1)) {
      if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
        return ItemStack.EMPTY;
      }
    } else if (this.dragonInv.getSizeInventory() <= 2 || !this.mergeItemStack(itemstack1, 2, this.dragonInv.getSizeInventory(), false)) {
      return ItemStack.EMPTY;
    }
    if (itemstack1.isEmpty()) {
      slot.putStack((ItemStack) ItemStack.EMPTY);
    } else {
      slot.onSlotChanged();
    }
  }
  return itemstack;
}

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

GlStateManager.disableBlend();
GlStateManager.disableDepth();
if (!gui.getDraggedItem().isEmpty() && !this.slot.isItemValid(gui.getDraggedItem())) {
  RenderUtil.drawGradientRect(new Area(1, 1, 16, 16), -1426089575, -1426089575);
} else {

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

if(inventorySlots.get(0).getHasStack() || !inventorySlots.get(0).isItemValid(itemstack1))
  return ItemStack.EMPTY;

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

public static ItemStack addItemInContainer(Container container, ItemStack itemStack) {
  for (int i = 0; i < container.inventorySlots.size(); i++) {
    if (container.getSlot(i).isItemValid(itemStack)) {
      if (StackUtils.isNullOrEmpty(container.getSlot(i).getStack())) {
        container.getSlot(i).putStack(itemStack);
        if (itemStack.getCount() > itemStack.getMaxStackSize()) {
          itemStack.setCount(itemStack.getMaxStackSize());
        } else {
          return null;
        }
      } else if (ItemStack.areItemStacksEqual(container.getSlot(i).getStack(), itemStack) && container.getSlot(i).getStack().getCount() < container.getSlot(i).getStack().getMaxStackSize()) {
        int newStackSize = Math.min(container.getSlot(i).getStack().getCount() + itemStack.getCount(), container.getSlot(i).getStack().getMaxStackSize());
        int leftStackSize = container.getSlot(i).getStack().getCount() + itemStack.getCount() - newStackSize;
        container.getSlot(i).getStack().setCount(newStackSize);
        if (leftStackSize <= 0) {
          return null;
        }
        itemStack.setCount(newStackSize);
      }
    }
  }
  return itemStack;
}

相关文章