if (nbt.hasKey("compounds")) { int compoundNumber = 0; NBTTagCompound compoundTags = nbt.getCompoundTag("compounds"); NBTTagCompound compoundTag; List compoundList = new ArrayList(); while (!(compoundTag = compoundTags.getCompoundTag("compound" + compoundNumber)).hasNoTags()) compoundList.add(Compound.from(compoundTag)); }