Java Code Examples for net.minecraft.nbt.NBTTagList.getIntAt()

The following are Jave code examples for showing how to use getIntAt() of the net.minecraft.nbt.NBTTagList class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Mods   File: TileEntityUpgrades.java   View Source Code Vote up 5 votes
@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	if (compound.hasKey("Attributes")) {
		NBTTagCompound attrs = compound.getCompoundTag("Attributes");
		NBTTagList attrList = (NBTTagList) compound.getTag("AttributesList");
		for (String key : attrs.getKeySet())
			this.attributes.put(TF2Attribute.attributes[Integer.parseInt(key)], attrs.getInteger(key));
		for (int i = 0; i < attrList.tagCount(); i++)
			this.attributeList[i] = TF2Attribute.attributes[attrList.getIntAt(i)];
	}
}
 
Example 2
Project: harshencastle   File: HarshenTemplate.java   View Source Code Vote up 4 votes
protected HarshenTemplate(ResourceLocation location) {
	String s = location.getResourceDomain();
       String s1 = location.getResourcePath();
       InputStream stream = null;
       boolean flag;
       try
       {
       	stream = getClass().getResourceAsStream("/assets/" + HarshenCastle.MODID + "/structures/" + s1 + ".nbt");
           NBTTagCompound compound = CompressedStreamTools.readCompressed(stream);
           if (!compound.hasKey("DataVersion", 99))
           {
           	compound.setInteger("DataVersion", 500);
           }
           Template template = new Template();
           DataFixer fixer;
           try
           {
           	fixer = Minecraft.getMinecraft().getDataFixer();
           }
           catch (Throwable e) {
			fixer = FMLServerHandler.instance().getDataFixer();
		}
           template.read(fixer.process(FixTypes.STRUCTURE, compound));
           this.blocks.clear();
           NBTTagList nbttaglist = compound.getTagList("size", 3);
           this.size = new BlockPos(nbttaglist.getIntAt(0), nbttaglist.getIntAt(1), nbttaglist.getIntAt(2));
           NBTTagList nbttaglist4 = compound.getTagList("pos", 3);
           if(nbttaglist4.hasNoTags())
           	this.pos = BlockPos.ORIGIN;
           else
               this.pos = new BlockPos(nbttaglist4.getIntAt(0), nbttaglist4.getIntAt(1), nbttaglist4.getIntAt(2));
           BasicPalette template$basicpalette = new BasicPalette();
           NBTTagList nbttaglist1 = compound.getTagList("palette", 10);

           for (int i = 0; i < nbttaglist1.tagCount(); ++i)
           {
               template$basicpalette.addMapping(NBTUtil.readBlockState(nbttaglist1.getCompoundTagAt(i)), i);
           }

           NBTTagList nbttaglist3 = compound.getTagList("blocks", 10);
           for (int j = 0; j < nbttaglist3.tagCount(); ++j)
           {
               NBTTagCompound nbttagcompound = nbttaglist3.getCompoundTagAt(j);
               NBTTagList nbttaglist2 = nbttagcompound.getTagList("pos", 3);
               BlockPos blockpos = new BlockPos(nbttaglist2.getIntAt(0), nbttaglist2.getIntAt(1), nbttaglist2.getIntAt(2));
               IBlockState iblockstate = template$basicpalette.stateFor(nbttagcompound.getInteger("state"));
               NBTTagCompound nbttagcompound1;

               if (nbttagcompound.hasKey("nbt"))
               {
                   nbttagcompound1 = nbttagcompound.getCompoundTag("nbt");
               }
               else
               {
                   nbttagcompound1 = null;
               }

               if(!(iblockstate.getBlock() instanceof BlockStructure))
               	this.blocks.add(new Template.BlockInfo(blockpos, iblockstate, nbttagcompound1));
           }
       }
       catch (Throwable var10)
       {
       }
       finally
       {
           IOUtils.closeQuietly(stream);
       }
}
 
Example 3
Project: harshencastle   File: HarshenTemplate.java   View Source Code Vote up 4 votes
public void read(NBTTagCompound compound)
{
    this.blocks.clear();
    this.entities.clear();
    NBTTagList nbttaglist = compound.getTagList("size", 3);
    this.size = new BlockPos(nbttaglist.getIntAt(0), nbttaglist.getIntAt(1), nbttaglist.getIntAt(2));
    this.author = compound.getString("author");
    BasicPalette template$basicpalette = new BasicPalette();
    NBTTagList nbttaglist1 = compound.getTagList("palette", 10);

    for (int i = 0; i < nbttaglist1.tagCount(); ++i)
    {
        template$basicpalette.addMapping(NBTUtil.readBlockState(nbttaglist1.getCompoundTagAt(i)), i);
    }

    NBTTagList nbttaglist3 = compound.getTagList("blocks", 10);

    for (int j = 0; j < nbttaglist3.tagCount(); ++j)
    {
        NBTTagCompound nbttagcompound = nbttaglist3.getCompoundTagAt(j);
        NBTTagList nbttaglist2 = nbttagcompound.getTagList("pos", 3);
        BlockPos blockpos = new BlockPos(nbttaglist2.getIntAt(0), nbttaglist2.getIntAt(1), nbttaglist2.getIntAt(2));
        IBlockState iblockstate = template$basicpalette.stateFor(nbttagcompound.getInteger("state"));
        NBTTagCompound nbttagcompound1;

        if (nbttagcompound.hasKey("nbt"))
        {
            nbttagcompound1 = nbttagcompound.getCompoundTag("nbt");
        }
        else
        {
            nbttagcompound1 = null;
        }

        this.blocks.add(new Template.BlockInfo(blockpos, iblockstate, nbttagcompound1));
    }

    NBTTagList nbttaglist4 = compound.getTagList("entities", 10);

    for (int k = 0; k < nbttaglist4.tagCount(); ++k)
    {
        NBTTagCompound nbttagcompound3 = nbttaglist4.getCompoundTagAt(k);
        NBTTagList nbttaglist5 = nbttagcompound3.getTagList("pos", 6);
        Vec3d vec3d = new Vec3d(nbttaglist5.getDoubleAt(0), nbttaglist5.getDoubleAt(1), nbttaglist5.getDoubleAt(2));
        NBTTagList nbttaglist6 = nbttagcompound3.getTagList("blockPos", 3);
        BlockPos blockpos1 = new BlockPos(nbttaglist6.getIntAt(0), nbttaglist6.getIntAt(1), nbttaglist6.getIntAt(2));

        if (nbttagcompound3.hasKey("nbt"))
        {
            NBTTagCompound nbttagcompound2 = nbttagcompound3.getCompoundTag("nbt");
            this.entities.add(new Template.EntityInfo(vec3d, blockpos1, nbttagcompound2));
        }
    }
}
 
Example 4
Project: Backmemed   File: Template.java   View Source Code Vote up 4 votes
public void read(NBTTagCompound compound)
{
    this.blocks.clear();
    this.entities.clear();
    NBTTagList nbttaglist = compound.getTagList("size", 3);
    this.size = new BlockPos(nbttaglist.getIntAt(0), nbttaglist.getIntAt(1), nbttaglist.getIntAt(2));
    this.author = compound.getString("author");
    Template.BasicPalette template$basicpalette = new Template.BasicPalette();
    NBTTagList nbttaglist1 = compound.getTagList("palette", 10);

    for (int i = 0; i < nbttaglist1.tagCount(); ++i)
    {
        template$basicpalette.addMapping(NBTUtil.readBlockState(nbttaglist1.getCompoundTagAt(i)), i);
    }

    NBTTagList nbttaglist3 = compound.getTagList("blocks", 10);

    for (int j = 0; j < nbttaglist3.tagCount(); ++j)
    {
        NBTTagCompound nbttagcompound = nbttaglist3.getCompoundTagAt(j);
        NBTTagList nbttaglist2 = nbttagcompound.getTagList("pos", 3);
        BlockPos blockpos = new BlockPos(nbttaglist2.getIntAt(0), nbttaglist2.getIntAt(1), nbttaglist2.getIntAt(2));
        IBlockState iblockstate = template$basicpalette.stateFor(nbttagcompound.getInteger("state"));
        NBTTagCompound nbttagcompound1;

        if (nbttagcompound.hasKey("nbt"))
        {
            nbttagcompound1 = nbttagcompound.getCompoundTag("nbt");
        }
        else
        {
            nbttagcompound1 = null;
        }

        this.blocks.add(new Template.BlockInfo(blockpos, iblockstate, nbttagcompound1));
    }

    NBTTagList nbttaglist4 = compound.getTagList("entities", 10);

    for (int k = 0; k < nbttaglist4.tagCount(); ++k)
    {
        NBTTagCompound nbttagcompound3 = nbttaglist4.getCompoundTagAt(k);
        NBTTagList nbttaglist5 = nbttagcompound3.getTagList("pos", 6);
        Vec3d vec3d = new Vec3d(nbttaglist5.getDoubleAt(0), nbttaglist5.getDoubleAt(1), nbttaglist5.getDoubleAt(2));
        NBTTagList nbttaglist6 = nbttagcompound3.getTagList("blockPos", 3);
        BlockPos blockpos1 = new BlockPos(nbttaglist6.getIntAt(0), nbttaglist6.getIntAt(1), nbttaglist6.getIntAt(2));

        if (nbttagcompound3.hasKey("nbt"))
        {
            NBTTagCompound nbttagcompound2 = nbttagcompound3.getCompoundTag("nbt");
            this.entities.add(new Template.EntityInfo(vec3d, blockpos1, nbttagcompound2));
        }
    }
}
 
Example 5
Project: CustomWorldGen   File: Template.java   View Source Code Vote up 4 votes
public void read(NBTTagCompound compound)
{
    this.blocks.clear();
    this.entities.clear();
    NBTTagList nbttaglist = compound.getTagList("size", 3);
    this.size = new BlockPos(nbttaglist.getIntAt(0), nbttaglist.getIntAt(1), nbttaglist.getIntAt(2));
    this.author = compound.getString("author");
    Template.BasicPalette template$basicpalette = new Template.BasicPalette();
    NBTTagList nbttaglist1 = compound.getTagList("palette", 10);

    for (int i = 0; i < nbttaglist1.tagCount(); ++i)
    {
        template$basicpalette.addMapping(NBTUtil.readBlockState(nbttaglist1.getCompoundTagAt(i)), i);
    }

    NBTTagList nbttaglist3 = compound.getTagList("blocks", 10);

    for (int j = 0; j < nbttaglist3.tagCount(); ++j)
    {
        NBTTagCompound nbttagcompound = nbttaglist3.getCompoundTagAt(j);
        NBTTagList nbttaglist2 = nbttagcompound.getTagList("pos", 3);
        BlockPos blockpos = new BlockPos(nbttaglist2.getIntAt(0), nbttaglist2.getIntAt(1), nbttaglist2.getIntAt(2));
        IBlockState iblockstate = template$basicpalette.stateFor(nbttagcompound.getInteger("state"));
        NBTTagCompound nbttagcompound1;

        if (nbttagcompound.hasKey("nbt"))
        {
            nbttagcompound1 = nbttagcompound.getCompoundTag("nbt");
        }
        else
        {
            nbttagcompound1 = null;
        }

        this.blocks.add(new Template.BlockInfo(blockpos, iblockstate, nbttagcompound1));
    }

    NBTTagList nbttaglist4 = compound.getTagList("entities", 10);

    for (int k = 0; k < nbttaglist4.tagCount(); ++k)
    {
        NBTTagCompound nbttagcompound3 = nbttaglist4.getCompoundTagAt(k);
        NBTTagList nbttaglist5 = nbttagcompound3.getTagList("pos", 6);
        Vec3d vec3d = new Vec3d(nbttaglist5.getDoubleAt(0), nbttaglist5.getDoubleAt(1), nbttaglist5.getDoubleAt(2));
        NBTTagList nbttaglist6 = nbttagcompound3.getTagList("blockPos", 3);
        BlockPos blockpos1 = new BlockPos(nbttaglist6.getIntAt(0), nbttaglist6.getIntAt(1), nbttaglist6.getIntAt(2));

        if (nbttagcompound3.hasKey("nbt"))
        {
            NBTTagCompound nbttagcompound2 = nbttagcompound3.getCompoundTag("nbt");
            this.entities.add(new Template.EntityInfo(vec3d, blockpos1, nbttagcompound2));
        }
    }
}