net.minecraft.util.NonNullList#withSize ( )源码实例Demo

下面列出了net.minecraft.util.NonNullList#withSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: TofuCraftReload   文件: TileEntitySaltFurnace.java
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);
    this.furnaceItemStacks = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY);
    ItemStackHelper.loadAllItems(par1NBTTagCompound, this.furnaceItemStacks);

    this.furnaceBurnTime = par1NBTTagCompound.getShort("BurnTime");
    this.cookTime = par1NBTTagCompound.getShort("CookTime");
    this.currentItemBurnTime = par1NBTTagCompound.getShort("ItemBurnTime");
    ;
    this.nigariTank.readFromNBT(par1NBTTagCompound.getCompoundTag("NigariTank"));

    if (par1NBTTagCompound.hasKey("CustomName")) {
        this.customName = par1NBTTagCompound.getString("CustomName");
    }
}
 
源代码2 项目: enderutilities   文件: ItemStackHandlerLockable.java
public ItemStackHandlerLockable(int inventoryId, int invSize, int stackLimit, boolean allowCustomStackSizes,
        String tagName, TileEntityEnderUtilitiesInventory te)
{
    super(inventoryId, invSize, stackLimit, allowCustomStackSizes, tagName, te);

    this.templateStacks = NonNullList.withSize(invSize, ItemStack.EMPTY);
    this.locked = new BitSet(invSize);
}
 
源代码3 项目: enderutilities   文件: ContainerMSU.java
public ContainerMSU(EntityPlayer player, TileEntityMSU te)
{
    super(player, te.getWrappedInventoryForContainer(player), te);
    this.temsu = te;
    this.inventoryNonWrapped = te.getInventoryMSU();

    int numSlots = this.inventoryNonWrapped.getSlots();
    this.lockedLast = new boolean[numSlots];
    this.templateStacksLast = NonNullList.withSize(numSlots, ItemStack.EMPTY);

    this.addCustomInventorySlots();
    this.addPlayerInventorySlots(8, 57);
}
 
源代码4 项目: customstuff4   文件: VanillaFurnaceRecipe.java
public VanillaFurnaceRecipe(ItemStack input)
{
    this.input = input;
    this.result = FurnaceRecipes.instance().getSmeltingResult(input);
    outputs = NonNullList.withSize(1, new SimpleMachineRecipeOutput(result));
    inputList = Collections.singletonList(new RecipeInputImpl(new WrappedItemStackConstant(input)));
}
 
源代码5 项目: EnderStorage   文件: CreateRecipe.java
@Nullable
@Override
public CreateRecipe read(ResourceLocation recipeId, PacketBuffer buffer) {
    String s = buffer.readString(32767);
    NonNullList<Ingredient> ingredients = NonNullList.withSize(3 * 3, Ingredient.EMPTY);

    for (int k = 0; k < ingredients.size(); ++k) {
        ingredients.set(k, Ingredient.read(buffer));
    }

    ItemStack result = buffer.readItemStack();
    return new CreateRecipe(recipeId, s, result, ingredients);
}
 
源代码6 项目: TofuCraftReload   文件: TileEntityTFStorage.java
public void readPacketNBT(NBTTagCompound cmp) {
    this.inventory =
            NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY);
    ItemStackHelper.loadAllItems(cmp, this.inventory);

    this.workload = cmp.getInteger("workload");
    this.current_workload = cmp.getInteger("current");

    this.tank.readFromNBT(cmp.getCompoundTag("Tank"));
}
 
源代码7 项目: ForgeHax   文件: Utils.java
public static List<ItemStack> getShulkerContents(ItemStack stack) { // TODO: move somewhere else
  NonNullList<ItemStack> contents = NonNullList.withSize(27, ItemStack.EMPTY);
  NBTTagCompound compound = stack.getTagCompound();
  if (compound != null && compound.hasKey("BlockEntityTag", 10)) {
    NBTTagCompound tags = compound.getCompoundTag("BlockEntityTag");
    if (tags.hasKey("Items", 9)) {
      // load in the items
      ItemStackHelper.loadAllItems(tags, contents);
    }
  }
  return contents;
}
 
源代码8 项目: GT-Classic   文件: GTTileUUMAssembler.java
/** Reads the inventory list from NBT **/
public static void readInventory(NBTTagCompound nbt, TileEntityElecMachine tile) {
	NBTTagList list = nbt.getTagList("Items", 10);
	tile.inventory = NonNullList.withSize(tile.slotCount, ItemStack.EMPTY);
	for (int i = 0; i < list.tagCount(); ++i) {
		NBTTagCompound data = list.getCompoundTagAt(i);
		int slot = data.getInteger("Slot");
		if (slot >= 0 && slot < tile.slotCount) {
			tile.inventory.set(slot, new ItemStack(data));
		}
	}
}
 
源代码9 项目: Sakura_mod   文件: TileEntityMapleCauldron.java
public void readPacketNBT(NBTTagCompound cmp) {
    this.inventory =
            NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
    ItemStackHelper.loadAllItems(cmp, this.inventory);
    this.mapleTime = cmp.getInteger("MapleTime");
    this.cookTime = cmp.getInteger("CookTime");
    this.tank.readFromNBT(cmp.getCompoundTag("Tank"));
}
 
源代码10 项目: Sakura_mod   文件: TileEntityDistillation.java
public void readPacketNBT(NBTTagCompound cmp) {
	this.inventory = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
	ItemStackHelper.loadAllItems(cmp, this.inventory);

	processTimer = cmp.getInteger(TAG_PROCESS);

	this.tank.readFromNBT(cmp.getCompoundTag("Tank"));
	this.resultTank.readFromNBT(cmp.getCompoundTag("ResultTank"));
}
 
源代码11 项目: Sakura_mod   文件: TileEntityCampfirePot.java
public void readPacketNBT(NBTTagCompound cmp) {
    this.inventory =
            NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
    ItemStackHelper.loadAllItems(cmp, this.inventory);
    this.burnTime = cmp.getInteger("BurnTime");
    this.cookTime = cmp.getInteger("CookTime");
    this.tank.readFromNBT(cmp.getCompoundTag("Tank"));
}
 
@Override
public void readFromNBT(NBTTagCompound compound) {
    this.inventory = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY);
    ItemStackHelper.loadAllItems(compound, this.inventory);
    super.readFromNBT(compound);
}
 
源代码13 项目: TofuCraftReload   文件: BlockTofuYuba.java
@Override
public NonNullList<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
    return NonNullList.withSize(1, new ItemStack(BlockLoader.yubaGrass, 1));
}
 
源代码14 项目: TofuCraftReload   文件: BlockUnderVine.java
@Override
public NonNullList<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
    return NonNullList.withSize(1, new ItemStack(this, 1));
}
 
源代码15 项目: TofuCraftReload   文件: BlockApricotLeaves.java
@Override
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
    return NonNullList.withSize(1, new ItemStack(this, 1));
}
 
源代码16 项目: Sakura_mod   文件: BlockMapleLeaveOrange.java
@Override
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
    return NonNullList.withSize(1, new ItemStack(this, 1));
}
 
源代码17 项目: Sakura_mod   文件: BlockMapleLeaveYellow.java
@Override
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
    return NonNullList.withSize(1, new ItemStack(this, 1));
}
 
源代码18 项目: seppuku   文件: ShulkerPreviewModule.java
@Listener
public void onRenderTooltip(EventRenderTooltip event) {
    if (event.getItemStack() == null)
        return;

    final Minecraft mc = Minecraft.getMinecraft();

    if (event.getItemStack().getItem() instanceof ItemShulkerBox) {
        ItemStack shulker = event.getItemStack();
        NBTTagCompound tagCompound = shulker.getTagCompound();
        if (tagCompound != null && tagCompound.hasKey("BlockEntityTag", 10)) {
            NBTTagCompound blockEntityTag = tagCompound.getCompoundTag("BlockEntityTag");
            if (blockEntityTag.hasKey("Items", 9)) {
                event.setCanceled(true); // cancel rendering the old tooltip

                NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>withSize(27, ItemStack.EMPTY);
                ItemStackHelper.loadAllItems(blockEntityTag, nonnulllist); // load the itemstacks from the tag to the list

                // store mouse/event coords
                int x = event.getX();
                int y = event.getY();

                // translate to mouse x, y
                GlStateManager.translate(x + 10, y - 5, 0);

                GlStateManager.disableLighting();
                GlStateManager.disableDepth();
                // background
                RenderUtil.drawRect(-3, -mc.fontRenderer.FONT_HEIGHT - 4, 9 * 16 + 3, 3 * 16 + 3, 0x99101010);
                RenderUtil.drawRect(-2, -mc.fontRenderer.FONT_HEIGHT - 3, 9 * 16 + 2, 3 * 16 + 2, 0xFF202020);
                RenderUtil.drawRect(0, 0, 9 * 16, 3 * 16, 0xFF101010);

                // text
                mc.fontRenderer.drawStringWithShadow(shulker.getDisplayName(), 0, -mc.fontRenderer.FONT_HEIGHT - 1, 0xFFFFFFFF);

                GlStateManager.enableDepth();
                mc.getRenderItem().zLevel = 150.0F;
                RenderHelper.enableGUIStandardItemLighting();

                // loop through items in shulker inventory
                for (int i = 0; i < nonnulllist.size(); i++) {
                    ItemStack itemStack = nonnulllist.get(i);
                    int offsetX = (i % 9) * 16;
                    int offsetY = (i / 9) * 16;
                    mc.getRenderItem().renderItemAndEffectIntoGUI(itemStack, offsetX, offsetY);
                    mc.getRenderItem().renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, offsetX, offsetY, null);
                }

                RenderHelper.disableStandardItemLighting();
                mc.getRenderItem().zLevel = 0.0F;
                GlStateManager.enableLighting();

                // reverse the translate
                GlStateManager.translate(-(x + 10), -(y - 5), 0);
            }
        }

        if(this.middleClick.getValue()) {
            if (Mouse.isButtonDown(2)) {
                if (!this.clicked) {
                    final BlockShulkerBox shulkerBox = (BlockShulkerBox) Block.getBlockFromItem(shulker.getItem());
                    if (shulkerBox != null) {
                        final NBTTagCompound tag = shulker.getTagCompound();
                        if (tag != null && tag.hasKey("BlockEntityTag", 10)) {
                            final NBTTagCompound entityTag = tag.getCompoundTag("BlockEntityTag");

                            final TileEntityShulkerBox te = new TileEntityShulkerBox();
                            te.setWorld(mc.world);
                            te.readFromNBT(entityTag);
                            mc.displayGuiScreen(new GuiShulkerBox(mc.player.inventory, te));
                        }
                    }
                }
                this.clicked = true;
            } else {
                this.clicked = false;
            }
        }
    }
}
 
源代码19 项目: customstuff4   文件: SimpleMachineRecipeOutput.java
public SimpleMachineRecipeOutput(ItemStack result)
{
    this.result = result;
    resultList = NonNullList.withSize(1, result);
}
 
源代码20 项目: NOVA-Core   文件: NovaCraftingRecipe.java
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inventory) {
	return NonNullList.withSize(0, ItemStack.EMPTY);
}