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

The following are Jave code examples for showing how to use getDoubleAt() 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: DecompiledMinecraft   File: EntityFireball.java   View Source Code Vote up 5 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    this.xTile = tagCompund.getShort("xTile");
    this.yTile = tagCompund.getShort("yTile");
    this.zTile = tagCompund.getShort("zTile");

    if (tagCompund.hasKey("inTile", 8))
    {
        this.inTile = Block.getBlockFromName(tagCompund.getString("inTile"));
    }
    else
    {
        this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255);
    }

    this.inGround = tagCompund.getByte("inGround") == 1;

    if (tagCompund.hasKey("direction", 9))
    {
        NBTTagList nbttaglist = tagCompund.getTagList("direction", 6);
        this.motionX = nbttaglist.getDoubleAt(0);
        this.motionY = nbttaglist.getDoubleAt(1);
        this.motionZ = nbttaglist.getDoubleAt(2);
    }
    else
    {
        this.setDead();
    }
}
 
Example 2
Project: DecompiledMinecraft   File: EntityFireball.java   View Source Code Vote up 5 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    this.xTile = tagCompund.getShort("xTile");
    this.yTile = tagCompund.getShort("yTile");
    this.zTile = tagCompund.getShort("zTile");

    if (tagCompund.hasKey("inTile", 8))
    {
        this.inTile = Block.getBlockFromName(tagCompund.getString("inTile"));
    }
    else
    {
        this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255);
    }

    this.inGround = tagCompund.getByte("inGround") == 1;

    if (tagCompund.hasKey("direction", 9))
    {
        NBTTagList nbttaglist = tagCompund.getTagList("direction", 6);
        this.motionX = nbttaglist.getDoubleAt(0);
        this.motionY = nbttaglist.getDoubleAt(1);
        this.motionZ = nbttaglist.getDoubleAt(2);
    }
    else
    {
        this.setDead();
    }
}
 
Example 3
Project: BaseClient   File: EntityFireball.java   View Source Code Vote up 5 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    this.xTile = tagCompund.getShort("xTile");
    this.yTile = tagCompund.getShort("yTile");
    this.zTile = tagCompund.getShort("zTile");

    if (tagCompund.hasKey("inTile", 8))
    {
        this.inTile = Block.getBlockFromName(tagCompund.getString("inTile"));
    }
    else
    {
        this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255);
    }

    this.inGround = tagCompund.getByte("inGround") == 1;

    if (tagCompund.hasKey("direction", 9))
    {
        NBTTagList nbttaglist = tagCompund.getTagList("direction", 6);
        this.motionX = nbttaglist.getDoubleAt(0);
        this.motionY = nbttaglist.getDoubleAt(1);
        this.motionZ = nbttaglist.getDoubleAt(2);
    }
    else
    {
        this.setDead();
    }
}
 
Example 4
Project: BaseClient   File: EntityFireball.java   View Source Code Vote up 5 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    this.xTile = tagCompund.getShort("xTile");
    this.yTile = tagCompund.getShort("yTile");
    this.zTile = tagCompund.getShort("zTile");

    if (tagCompund.hasKey("inTile", 8))
    {
        this.inTile = Block.getBlockFromName(tagCompund.getString("inTile"));
    }
    else
    {
        this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255);
    }

    this.inGround = tagCompund.getByte("inGround") == 1;

    if (tagCompund.hasKey("direction", 9))
    {
        NBTTagList nbttaglist = tagCompund.getTagList("direction", 6);
        this.motionX = nbttaglist.getDoubleAt(0);
        this.motionY = nbttaglist.getDoubleAt(1);
        this.motionZ = nbttaglist.getDoubleAt(2);
    }
    else
    {
        this.setDead();
    }
}
 
Example 5
Project: Backmemed   File: EntityFireball.java   View Source Code Vote up 5 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound)
{
    if (compound.hasKey("power", 9))
    {
        NBTTagList nbttaglist = compound.getTagList("power", 6);

        if (nbttaglist.tagCount() == 3)
        {
            this.accelerationX = nbttaglist.getDoubleAt(0);
            this.accelerationY = nbttaglist.getDoubleAt(1);
            this.accelerationZ = nbttaglist.getDoubleAt(2);
        }
    }

    this.ticksAlive = compound.getInteger("life");

    if (compound.hasKey("direction", 9) && compound.getTagList("direction", 6).tagCount() == 3)
    {
        NBTTagList nbttaglist1 = compound.getTagList("direction", 6);
        this.motionX = nbttaglist1.getDoubleAt(0);
        this.motionY = nbttaglist1.getDoubleAt(1);
        this.motionZ = nbttaglist1.getDoubleAt(2);
    }
    else
    {
        this.setDead();
    }
}
 
Example 6
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 7
Project: DecompiledMinecraft   File: Entity.java   View Source Code Vote up 4 votes
/**
 * Reads the entity from NBT (calls an abstract helper method to read specialized data)
 */
public void readFromNBT(NBTTagCompound tagCompund)
{
    try
    {
        NBTTagList nbttaglist = tagCompund.getTagList("Pos", 6);
        NBTTagList nbttaglist1 = tagCompund.getTagList("Motion", 6);
        NBTTagList nbttaglist2 = tagCompund.getTagList("Rotation", 5);
        this.motionX = nbttaglist1.getDoubleAt(0);
        this.motionY = nbttaglist1.getDoubleAt(1);
        this.motionZ = nbttaglist1.getDoubleAt(2);

        if (Math.abs(this.motionX) > 10.0D)
        {
            this.motionX = 0.0D;
        }

        if (Math.abs(this.motionY) > 10.0D)
        {
            this.motionY = 0.0D;
        }

        if (Math.abs(this.motionZ) > 10.0D)
        {
            this.motionZ = 0.0D;
        }

        this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.getDoubleAt(0);
        this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.getDoubleAt(1);
        this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.getDoubleAt(2);
        this.prevRotationYaw = this.rotationYaw = nbttaglist2.getFloatAt(0);
        this.prevRotationPitch = this.rotationPitch = nbttaglist2.getFloatAt(1);
        this.setRotationYawHead(this.rotationYaw);
        this.func_181013_g(this.rotationYaw);
        this.fallDistance = tagCompund.getFloat("FallDistance");
        this.fire = tagCompund.getShort("Fire");
        this.setAir(tagCompund.getShort("Air"));
        this.onGround = tagCompund.getBoolean("OnGround");
        this.dimension = tagCompund.getInteger("Dimension");
        this.invulnerable = tagCompund.getBoolean("Invulnerable");
        this.timeUntilPortal = tagCompund.getInteger("PortalCooldown");

        if (tagCompund.hasKey("UUIDMost", 4) && tagCompund.hasKey("UUIDLeast", 4))
        {
            this.entityUniqueID = new UUID(tagCompund.getLong("UUIDMost"), tagCompund.getLong("UUIDLeast"));
        }
        else if (tagCompund.hasKey("UUID", 8))
        {
            this.entityUniqueID = UUID.fromString(tagCompund.getString("UUID"));
        }

        this.setPosition(this.posX, this.posY, this.posZ);
        this.setRotation(this.rotationYaw, this.rotationPitch);

        if (tagCompund.hasKey("CustomName", 8) && tagCompund.getString("CustomName").length() > 0)
        {
            this.setCustomNameTag(tagCompund.getString("CustomName"));
        }

        this.setAlwaysRenderNameTag(tagCompund.getBoolean("CustomNameVisible"));
        this.cmdResultStats.readStatsFromNBT(tagCompund);
        this.setSilent(tagCompund.getBoolean("Silent"));
        this.readEntityFromNBT(tagCompund);

        if (this.shouldSetPosAfterLoading())
        {
            this.setPosition(this.posX, this.posY, this.posZ);
        }
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Loading entity NBT");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being loaded");
        this.addEntityCrashInfo(crashreportcategory);
        throw new ReportedException(crashreport);
    }
}
 
Example 8
Project: DecompiledMinecraft   File: Entity.java   View Source Code Vote up 4 votes
/**
 * Reads the entity from NBT (calls an abstract helper method to read specialized data)
 */
public void readFromNBT(NBTTagCompound tagCompund)
{
    try
    {
        NBTTagList nbttaglist = tagCompund.getTagList("Pos", 6);
        NBTTagList nbttaglist1 = tagCompund.getTagList("Motion", 6);
        NBTTagList nbttaglist2 = tagCompund.getTagList("Rotation", 5);
        this.motionX = nbttaglist1.getDoubleAt(0);
        this.motionY = nbttaglist1.getDoubleAt(1);
        this.motionZ = nbttaglist1.getDoubleAt(2);

        if (Math.abs(this.motionX) > 10.0D)
        {
            this.motionX = 0.0D;
        }

        if (Math.abs(this.motionY) > 10.0D)
        {
            this.motionY = 0.0D;
        }

        if (Math.abs(this.motionZ) > 10.0D)
        {
            this.motionZ = 0.0D;
        }

        this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.getDoubleAt(0);
        this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.getDoubleAt(1);
        this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.getDoubleAt(2);
        this.prevRotationYaw = this.rotationYaw = nbttaglist2.getFloatAt(0);
        this.prevRotationPitch = this.rotationPitch = nbttaglist2.getFloatAt(1);
        this.setRotationYawHead(this.rotationYaw);
        this.func_181013_g(this.rotationYaw);
        this.fallDistance = tagCompund.getFloat("FallDistance");
        this.fire = tagCompund.getShort("Fire");
        this.setAir(tagCompund.getShort("Air"));
        this.onGround = tagCompund.getBoolean("OnGround");
        this.dimension = tagCompund.getInteger("Dimension");
        this.invulnerable = tagCompund.getBoolean("Invulnerable");
        this.timeUntilPortal = tagCompund.getInteger("PortalCooldown");

        if (tagCompund.hasKey("UUIDMost", 4) && tagCompund.hasKey("UUIDLeast", 4))
        {
            this.entityUniqueID = new UUID(tagCompund.getLong("UUIDMost"), tagCompund.getLong("UUIDLeast"));
        }
        else if (tagCompund.hasKey("UUID", 8))
        {
            this.entityUniqueID = UUID.fromString(tagCompund.getString("UUID"));
        }

        this.setPosition(this.posX, this.posY, this.posZ);
        this.setRotation(this.rotationYaw, this.rotationPitch);

        if (tagCompund.hasKey("CustomName", 8) && tagCompund.getString("CustomName").length() > 0)
        {
            this.setCustomNameTag(tagCompund.getString("CustomName"));
        }

        this.setAlwaysRenderNameTag(tagCompund.getBoolean("CustomNameVisible"));
        this.cmdResultStats.readStatsFromNBT(tagCompund);
        this.setSilent(tagCompund.getBoolean("Silent"));
        this.readEntityFromNBT(tagCompund);

        if (this.shouldSetPosAfterLoading())
        {
            this.setPosition(this.posX, this.posY, this.posZ);
        }
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Loading entity NBT");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being loaded");
        this.addEntityCrashInfo(crashreportcategory);
        throw new ReportedException(crashreport);
    }
}
 
Example 9
Project: BaseClient   File: Entity.java   View Source Code Vote up 4 votes
/**
 * Reads the entity from NBT (calls an abstract helper method to read specialized data)
 */
public void readFromNBT(NBTTagCompound tagCompund)
{
    try
    {
        NBTTagList nbttaglist = tagCompund.getTagList("Pos", 6);
        NBTTagList nbttaglist1 = tagCompund.getTagList("Motion", 6);
        NBTTagList nbttaglist2 = tagCompund.getTagList("Rotation", 5);
        this.motionX = nbttaglist1.getDoubleAt(0);
        this.motionY = nbttaglist1.getDoubleAt(1);
        this.motionZ = nbttaglist1.getDoubleAt(2);

        if (Math.abs(this.motionX) > 10.0D)
        {
            this.motionX = 0.0D;
        }

        if (Math.abs(this.motionY) > 10.0D)
        {
            this.motionY = 0.0D;
        }

        if (Math.abs(this.motionZ) > 10.0D)
        {
            this.motionZ = 0.0D;
        }

        this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.getDoubleAt(0);
        this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.getDoubleAt(1);
        this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.getDoubleAt(2);
        this.prevRotationYaw = this.rotationYaw = nbttaglist2.getFloatAt(0);
        this.prevRotationPitch = this.rotationPitch = nbttaglist2.getFloatAt(1);
        this.setRotationYawHead(this.rotationYaw);
        this.func_181013_g(this.rotationYaw);
        this.fallDistance = tagCompund.getFloat("FallDistance");
        this.fire = tagCompund.getShort("Fire");
        this.setAir(tagCompund.getShort("Air"));
        this.onGround = tagCompund.getBoolean("OnGround");
        this.dimension = tagCompund.getInteger("Dimension");
        this.invulnerable = tagCompund.getBoolean("Invulnerable");
        this.timeUntilPortal = tagCompund.getInteger("PortalCooldown");

        if (tagCompund.hasKey("UUIDMost", 4) && tagCompund.hasKey("UUIDLeast", 4))
        {
            this.entityUniqueID = new UUID(tagCompund.getLong("UUIDMost"), tagCompund.getLong("UUIDLeast"));
        }
        else if (tagCompund.hasKey("UUID", 8))
        {
            this.entityUniqueID = UUID.fromString(tagCompund.getString("UUID"));
        }

        this.setPosition(this.posX, this.posY, this.posZ);
        this.setRotation(this.rotationYaw, this.rotationPitch);

        if (tagCompund.hasKey("CustomName", 8) && tagCompund.getString("CustomName").length() > 0)
        {
            this.setCustomNameTag(tagCompund.getString("CustomName"));
        }

        this.setAlwaysRenderNameTag(tagCompund.getBoolean("CustomNameVisible"));
        this.cmdResultStats.readStatsFromNBT(tagCompund);
        this.setSilent(tagCompund.getBoolean("Silent"));
        this.readEntityFromNBT(tagCompund);

        if (this.shouldSetPosAfterLoading())
        {
            this.setPosition(this.posX, this.posY, this.posZ);
        }
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Loading entity NBT");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being loaded");
        this.addEntityCrashInfo(crashreportcategory);
        throw new ReportedException(crashreport);
    }
}
 
Example 10
Project: BaseClient   File: Entity.java   View Source Code Vote up 4 votes
/**
 * Reads the entity from NBT (calls an abstract helper method to read specialized data)
 */
public void readFromNBT(NBTTagCompound tagCompund)
{
    try
    {
        NBTTagList nbttaglist = tagCompund.getTagList("Pos", 6);
        NBTTagList nbttaglist1 = tagCompund.getTagList("Motion", 6);
        NBTTagList nbttaglist2 = tagCompund.getTagList("Rotation", 5);
        this.motionX = nbttaglist1.getDoubleAt(0);
        this.motionY = nbttaglist1.getDoubleAt(1);
        this.motionZ = nbttaglist1.getDoubleAt(2);

        if (Math.abs(this.motionX) > 10.0D)
        {
            this.motionX = 0.0D;
        }

        if (Math.abs(this.motionY) > 10.0D)
        {
            this.motionY = 0.0D;
        }

        if (Math.abs(this.motionZ) > 10.0D)
        {
            this.motionZ = 0.0D;
        }

        this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.getDoubleAt(0);
        this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.getDoubleAt(1);
        this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.getDoubleAt(2);
        this.prevRotationYaw = this.rotationYaw = nbttaglist2.getFloatAt(0);
        this.prevRotationPitch = this.rotationPitch = nbttaglist2.getFloatAt(1);
        this.setRotationYawHead(this.rotationYaw);
        this.func_181013_g(this.rotationYaw);
        this.fallDistance = tagCompund.getFloat("FallDistance");
        this.fire = tagCompund.getShort("Fire");
        this.setAir(tagCompund.getShort("Air"));
        this.onGround = tagCompund.getBoolean("OnGround");
        this.dimension = tagCompund.getInteger("Dimension");
        this.invulnerable = tagCompund.getBoolean("Invulnerable");
        this.timeUntilPortal = tagCompund.getInteger("PortalCooldown");

        if (tagCompund.hasKey("UUIDMost", 4) && tagCompund.hasKey("UUIDLeast", 4))
        {
            this.entityUniqueID = new UUID(tagCompund.getLong("UUIDMost"), tagCompund.getLong("UUIDLeast"));
        }
        else if (tagCompund.hasKey("UUID", 8))
        {
            this.entityUniqueID = UUID.fromString(tagCompund.getString("UUID"));
        }

        this.setPosition(this.posX, this.posY, this.posZ);
        this.setRotation(this.rotationYaw, this.rotationPitch);

        if (tagCompund.hasKey("CustomName", 8) && tagCompund.getString("CustomName").length() > 0)
        {
            this.setCustomNameTag(tagCompund.getString("CustomName"));
        }

        this.setAlwaysRenderNameTag(tagCompund.getBoolean("CustomNameVisible"));
        this.cmdResultStats.readStatsFromNBT(tagCompund);
        this.setSilent(tagCompund.getBoolean("Silent"));
        this.readEntityFromNBT(tagCompund);

        if (this.shouldSetPosAfterLoading())
        {
            this.setPosition(this.posX, this.posY, this.posZ);
        }
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Loading entity NBT");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being loaded");
        this.addEntityCrashInfo(crashreportcategory);
        throw new ReportedException(crashreport);
    }
}
 
Example 11
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 12
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));
        }
    }
}
 
Example 13
Project: CustomWorldGen   File: EntityFireball.java   View Source Code Vote up 4 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound)
{
    this.xTile = compound.getInteger("xTile");
    this.yTile = compound.getInteger("yTile");
    this.zTile = compound.getInteger("zTile");

    if (compound.hasKey("inTile", 8))
    {
        this.inTile = Block.getBlockFromName(compound.getString("inTile"));
    }
    else
    {
        this.inTile = Block.getBlockById(compound.getByte("inTile") & 255);
    }

    this.inGround = compound.getByte("inGround") == 1;

    if (compound.hasKey("power", 9))
    {
        NBTTagList nbttaglist = compound.getTagList("power", 6);

        if (nbttaglist.tagCount() == 3)
        {
            this.accelerationX = nbttaglist.getDoubleAt(0);
            this.accelerationY = nbttaglist.getDoubleAt(1);
            this.accelerationZ = nbttaglist.getDoubleAt(2);
        }
    }

    this.ticksAlive = compound.getInteger("life");

    if (compound.hasKey("direction", 9) && compound.getTagList("direction", 6).tagCount() == 3)
    {
        NBTTagList nbttaglist1 = compound.getTagList("direction", 6);
        this.motionX = nbttaglist1.getDoubleAt(0);
        this.motionY = nbttaglist1.getDoubleAt(1);
        this.motionZ = nbttaglist1.getDoubleAt(2);
    }
    else
    {
        this.setDead();
    }
}