net.minecraft.util.NonNullList.withSize()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(81)

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

NonNullList.withSize介绍

暂无

代码示例

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

primer.height = pattern.length;
primer.mirrored = JsonUtils.getBoolean( json, "mirrored", true );
primer.input = NonNullList.withSize( primer.width * primer.height, net.minecraft.item.crafting.Ingredient.EMPTY );

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

public InventoryPlain(int size, String name, int stackLimit) {
  this.contents = NonNullList.withSize(size, ItemStack.EMPTY);
  this.name = name;
  this.stackLimit = stackLimit;
}

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

public EntityAnimatedChest(World world) {
  super(world);
  inventory = NonNullList.<ItemStack>withSize(27, ItemStack.EMPTY);
  isImmuneToFire = true;
}

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

public static NonNullList<String> getOreDictAsList(String[][] oreDicts) {
  NonNullList<String> result = NonNullList.withSize(9, "");
  if (oreDicts == null || oreDicts.length == 0) {
    return result;
  }
  for (int i = 0; i < oreDicts.length; i++) {
    for (int d = 0; d < oreDicts[i].length; d++) {
      result.set(i * 3 + d, oreDicts[d][i]);
    }
  }
  return result;
}

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

@Override
public NonNullList<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune)
{
  return NonNullList.withSize(1, new ItemStack(this));
}

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

public TileInventory(int size, String name) {
  this.inventory = NonNullList.withSize(size, ItemStack.EMPTY);
  this.size = size;
  this.name = name;
  initializeItemHandlers();
}

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

public ItemInventory(ItemStack masterStack, int size, String name) {
  this.inventory = NonNullList.withSize(size, ItemStack.EMPTY);
  this.size = size;
  this.name = name;
  this.masterStack = masterStack;
  if (!masterStack.isEmpty())
    this.readFromStack(masterStack);
}

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

public static NonNullList<ItemStack> getStacks(IInventory inventory, int slot1, int length) {
  NonNullList<ItemStack> result = NonNullList.withSize(length, ItemStack.EMPTY);
  for (int i = slot1; i < slot1 + length; i++) {
    result.set(i - slot1, inventory.getStackInSlot(i));
  }
  return result;
}

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

@Override
public NonNullList<ItemStack> getDisplayItems() {
  if (block == null) {
    Preconditions.checkNotNull(blockState);
    return NonNullList.withSize(1, new ItemStack(blockState.getBlock(), 1, blockState.getBlock().getMetaFromState(blockState)));
  } else if (blockState == null) {
    Preconditions.checkNotNull(block);
    return NonNullList.withSize(1, new ItemStack(block));
  }
  return NonNullList.create();
}

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

@Override
public void readFromNBT(NBTTagCompound compound) {
  super.readFromNBT(compound);
  this.stacks = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
  ItemStackHelper.loadAllItems(compound, this.stacks);
}

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

public void loadFromNbt(NBTTagCompound compound) {
  inventory = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
  if (compound.hasKey("Items", 9))
    ItemStackHelper.loadAllItems(compound, inventory);
}

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

public static NonNullList<ItemStack> getStacks(IInventory inventory) {
  NonNullList<ItemStack> stacks = NonNullList.withSize(inventory.getSizeInventory(), ItemStack.EMPTY);
  for (int i = 0; i < inventory.getSizeInventory(); i++) {
    stacks.set(i, inventory.getStackInSlot(i));
  }
  return stacks;
}

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

@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
  NonNullList<ItemStack> aitemstack = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
  for (int i = 0; i < inv.getSizeInventory(); ++i) {
    ItemStack itemstack = inv.getStackInSlot(i);
    aitemstack.set(i, ForgeHooks.getContainerItem(itemstack));
  }
  return aitemstack;
}

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

public NpcEquipmentHandler(NpcBase npc) {
  super(SIZE_INVENTORY);
  this.npc = npc;
  stacks = NonNullList.withSize(SIZE_INVENTORY, ItemStack.EMPTY);
  for (int i = 0; i < SIZE_INVENTORY; i++) {
    if (!npc.getItemStackFromSlot(i).isEmpty()) {
      stacks.set(i, npc.getItemStackFromSlot(i).copy());
    }
  }
}

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

@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inventory) {
  NonNullList<ItemStack> aitemstack = NonNullList.withSize(inventory.getSizeInventory(), ItemStack.EMPTY);
  for (int i = 0; i < aitemstack.size(); ++i) {
    ItemStack itemstack = inventory.getStackInSlot(i);
    aitemstack.set(i, net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack));
  }
  return aitemstack;
}

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

public <T extends TileEntity & ISocketable> PacketSocketUpdate(T tile) {
  this.pos = tile.getPos();
  this.itemStacks = NonNullList.withSize(tile.getSocketCount(), ItemStack.EMPTY);
  for (int i = 0; i < tile.getSocketCount(); i++) {
    this.itemStacks.set(i, tile.getSocket(i));
  }
}

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

public NonNullList<Ingredient> getIngredients() {
  NonNullList<Ingredient> list = NonNullList.withSize(1 + EnderdragonScales.required, Ingredient.EMPTY);
  list.set(0, Ingredient.fromStacks(new ItemStack(Items.ELYTRA)));
  for(int i = 1; i < EnderdragonScales.required + 1; i++)
    list.set(i, Ingredient.fromStacks(new ItemStack(EnderdragonScales.enderdragonScale)));
  return list;
}

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

public NonNullList<Ingredient> getIngredients() {
  NonNullList<Ingredient> list = NonNullList.withSize(2, Ingredient.EMPTY);
  list.set(0, Ingredient.fromStacks(new ItemStack(Items.ELYTRA)));
  
  ItemStack[] stacks = new ItemStack[16];
  for(int i = 0; i < 16; i++)
    stacks[i] = new ItemStack(Items.DYE, 1, i);
  list.set(1, Ingredient.fromStacks(stacks));
  return list;
}

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

public void readFromNBT(NBTTagCompound compound) {
  houseType = compound.getInteger("HouseType");
  hasPixie = compound.getBoolean("HasPixie");
  pixieType = compound.getInteger("PixieType");
  tamedPixie = compound.getBoolean("TamedPixie");
  pixieOwnerUUID = compound.getUniqueId("TicksExisted");
  this.pixieItems = NonNullList.<ItemStack>withSize(1, ItemStack.EMPTY);
  ItemStackHelper.loadAllItems(compound, pixieItems);
  super.readFromNBT(compound);
}

代码示例来源:origin: lorddusk/HQM

private void countItems(EntityPlayer player, ItemStack stack) {
  if(!player.getEntityWorld().isRemote){
    NonNullList<ItemStack> items = NonNullList.withSize(player.inventory.mainInventory.size() + 1, ItemStack.EMPTY);
    Collections.copy(items, player.inventory.mainInventory);
    if(!stack.isEmpty()){
      items.set(items.size() - 1, stack);
    }
    countItems(items, (QuestDataTaskItems) getData(player), player.getPersistentID());
  }
}

相关文章