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

The following are Jave code examples for showing how to use getFloatAt() 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.
Example 1
Project: Backmemed   File: RedundantChanceTags.java   Source Code and License Vote up 6 votes
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
{
    if (compound.hasKey("HandDropChances", 9))
    {
        NBTTagList nbttaglist = compound.getTagList("HandDropChances", 5);

        if (nbttaglist.tagCount() == 2 && nbttaglist.getFloatAt(0) == 0.0F && nbttaglist.getFloatAt(1) == 0.0F)
        {
            compound.removeTag("HandDropChances");
        }
    }

    if (compound.hasKey("ArmorDropChances", 9))
    {
        NBTTagList nbttaglist1 = compound.getTagList("ArmorDropChances", 5);

        if (nbttaglist1.tagCount() == 4 && nbttaglist1.getFloatAt(0) == 0.0F && nbttaglist1.getFloatAt(1) == 0.0F && nbttaglist1.getFloatAt(2) == 0.0F && nbttaglist1.getFloatAt(3) == 0.0F)
        {
            compound.removeTag("ArmorDropChances");
        }
    }

    return compound;
}
 
Example 2
Project: CustomWorldGen   File: RedundantChanceTags.java   Source Code and License Vote up 6 votes
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
{
    if (compound.hasKey("HandDropChances", 9))
    {
        NBTTagList nbttaglist = compound.getTagList("HandDropChances", 5);

        if (nbttaglist.tagCount() == 2 && nbttaglist.getFloatAt(0) == 0.0F && nbttaglist.getFloatAt(1) == 0.0F)
        {
            compound.removeTag("HandDropChances");
        }
    }

    if (compound.hasKey("ArmorDropChances", 9))
    {
        NBTTagList nbttaglist1 = compound.getTagList("ArmorDropChances", 5);

        if (nbttaglist1.tagCount() == 4 && nbttaglist1.getFloatAt(0) == 0.0F && nbttaglist1.getFloatAt(1) == 0.0F && nbttaglist1.getFloatAt(2) == 0.0F && nbttaglist1.getFloatAt(3) == 0.0F)
        {
            compound.removeTag("ArmorDropChances");
        }
    }

    return compound;
}
 
Example 3
Project: BaseClient   File: EntityLiving.java   Source Code and License Vote up 4 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    super.readEntityFromNBT(tagCompund);

    if (tagCompund.hasKey("CanPickUpLoot", 1))
    {
        this.setCanPickUpLoot(tagCompund.getBoolean("CanPickUpLoot"));
    }

    this.persistenceRequired = tagCompund.getBoolean("PersistenceRequired");

    if (tagCompund.hasKey("Equipment", 9))
    {
        NBTTagList nbttaglist = tagCompund.getTagList("Equipment", 10);

        for (int i = 0; i < this.equipment.length; ++i)
        {
            this.equipment[i] = ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i));
        }
    }

    if (tagCompund.hasKey("DropChances", 9))
    {
        NBTTagList nbttaglist1 = tagCompund.getTagList("DropChances", 5);

        for (int j = 0; j < nbttaglist1.tagCount(); ++j)
        {
            this.equipmentDropChances[j] = nbttaglist1.getFloatAt(j);
        }
    }

    this.isLeashed = tagCompund.getBoolean("Leashed");

    if (this.isLeashed && tagCompund.hasKey("Leash", 10))
    {
        this.leashNBTTag = tagCompund.getCompoundTag("Leash");
    }

    this.setNoAI(tagCompund.getBoolean("NoAI"));
}
 
Example 4
Project: BaseClient   File: Entity.java   Source Code and License 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 5
Project: BaseClient   File: Rotations.java   Source Code and License Vote up 4 votes
public Rotations(NBTTagList nbt)
{
    this.x = nbt.getFloatAt(0);
    this.y = nbt.getFloatAt(1);
    this.z = nbt.getFloatAt(2);
}
 
Example 6
Project: BaseClient   File: EntityLiving.java   Source Code and License Vote up 4 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    super.readEntityFromNBT(tagCompund);

    if (tagCompund.hasKey("CanPickUpLoot", 1))
    {
        this.setCanPickUpLoot(tagCompund.getBoolean("CanPickUpLoot"));
    }

    this.persistenceRequired = tagCompund.getBoolean("PersistenceRequired");

    if (tagCompund.hasKey("Equipment", 9))
    {
        NBTTagList nbttaglist = tagCompund.getTagList("Equipment", 10);

        for (int i = 0; i < this.equipment.length; ++i)
        {
            this.equipment[i] = ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i));
        }
    }

    if (tagCompund.hasKey("DropChances", 9))
    {
        NBTTagList nbttaglist1 = tagCompund.getTagList("DropChances", 5);

        for (int j = 0; j < nbttaglist1.tagCount(); ++j)
        {
            this.equipmentDropChances[j] = nbttaglist1.getFloatAt(j);
        }
    }

    this.isLeashed = tagCompund.getBoolean("Leashed");

    if (this.isLeashed && tagCompund.hasKey("Leash", 10))
    {
        this.leashNBTTag = tagCompund.getCompoundTag("Leash");
    }

    this.setNoAI(tagCompund.getBoolean("NoAI"));
}
 
Example 7
Project: BaseClient   File: Entity.java   Source Code and License 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: BaseClient   File: Rotations.java   Source Code and License Vote up 4 votes
public Rotations(NBTTagList nbt)
{
    this.x = nbt.getFloatAt(0);
    this.y = nbt.getFloatAt(1);
    this.z = nbt.getFloatAt(2);
}
 
Example 9
Project: Backmemed   File: EntityLiving.java   Source Code and License Vote up 4 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);

    if (compound.hasKey("CanPickUpLoot", 1))
    {
        this.setCanPickUpLoot(compound.getBoolean("CanPickUpLoot"));
    }

    this.persistenceRequired = compound.getBoolean("PersistenceRequired");

    if (compound.hasKey("ArmorItems", 9))
    {
        NBTTagList nbttaglist = compound.getTagList("ArmorItems", 10);

        for (int i = 0; i < this.inventoryArmor.size(); ++i)
        {
            this.inventoryArmor.set(i, new ItemStack(nbttaglist.getCompoundTagAt(i)));
        }
    }

    if (compound.hasKey("HandItems", 9))
    {
        NBTTagList nbttaglist1 = compound.getTagList("HandItems", 10);

        for (int j = 0; j < this.inventoryHands.size(); ++j)
        {
            this.inventoryHands.set(j, new ItemStack(nbttaglist1.getCompoundTagAt(j)));
        }
    }

    if (compound.hasKey("ArmorDropChances", 9))
    {
        NBTTagList nbttaglist2 = compound.getTagList("ArmorDropChances", 5);

        for (int k = 0; k < nbttaglist2.tagCount(); ++k)
        {
            this.inventoryArmorDropChances[k] = nbttaglist2.getFloatAt(k);
        }
    }

    if (compound.hasKey("HandDropChances", 9))
    {
        NBTTagList nbttaglist3 = compound.getTagList("HandDropChances", 5);

        for (int l = 0; l < nbttaglist3.tagCount(); ++l)
        {
            this.inventoryHandsDropChances[l] = nbttaglist3.getFloatAt(l);
        }
    }

    this.isLeashed = compound.getBoolean("Leashed");

    if (this.isLeashed && compound.hasKey("Leash", 10))
    {
        this.leashNBTTag = compound.getCompoundTag("Leash");
    }

    this.setLeftHanded(compound.getBoolean("LeftHanded"));

    if (compound.hasKey("DeathLootTable", 8))
    {
        this.deathLootTable = new ResourceLocation(compound.getString("DeathLootTable"));
        this.deathLootTableSeed = compound.getLong("DeathLootTableSeed");
    }

    this.setNoAI(compound.getBoolean("NoAI"));
}
 
Example 10
Project: Backmemed   File: Rotations.java   Source Code and License Vote up 4 votes
public Rotations(NBTTagList nbt)
{
    this.x = nbt.getFloatAt(0);
    this.y = nbt.getFloatAt(1);
    this.z = nbt.getFloatAt(2);
}
 
Example 11
Project: CustomWorldGen   File: EntityLiving.java   Source Code and License Vote up 4 votes
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);

    if (compound.hasKey("CanPickUpLoot", 1))
    {
        this.setCanPickUpLoot(compound.getBoolean("CanPickUpLoot"));
    }

    this.persistenceRequired = compound.getBoolean("PersistenceRequired");

    if (compound.hasKey("ArmorItems", 9))
    {
        NBTTagList nbttaglist = compound.getTagList("ArmorItems", 10);

        for (int i = 0; i < this.inventoryArmor.length; ++i)
        {
            this.inventoryArmor[i] = ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i));
        }
    }

    if (compound.hasKey("HandItems", 9))
    {
        NBTTagList nbttaglist1 = compound.getTagList("HandItems", 10);

        for (int j = 0; j < this.inventoryHands.length; ++j)
        {
            this.inventoryHands[j] = ItemStack.loadItemStackFromNBT(nbttaglist1.getCompoundTagAt(j));
        }
    }

    if (compound.hasKey("ArmorDropChances", 9))
    {
        NBTTagList nbttaglist2 = compound.getTagList("ArmorDropChances", 5);

        for (int k = 0; k < nbttaglist2.tagCount(); ++k)
        {
            this.inventoryArmorDropChances[k] = nbttaglist2.getFloatAt(k);
        }
    }

    if (compound.hasKey("HandDropChances", 9))
    {
        NBTTagList nbttaglist3 = compound.getTagList("HandDropChances", 5);

        for (int l = 0; l < nbttaglist3.tagCount(); ++l)
        {
            this.inventoryHandsDropChances[l] = nbttaglist3.getFloatAt(l);
        }
    }

    this.isLeashed = compound.getBoolean("Leashed");

    if (this.isLeashed && compound.hasKey("Leash", 10))
    {
        this.leashNBTTag = compound.getCompoundTag("Leash");
    }

    this.setLeftHanded(compound.getBoolean("LeftHanded"));

    if (compound.hasKey("DeathLootTable", 8))
    {
        this.deathLootTable = new ResourceLocation(compound.getString("DeathLootTable"));
        this.deathLootTableSeed = compound.getLong("DeathLootTableSeed");
    }

    this.setNoAI(compound.getBoolean("NoAI"));
}
 
Example 12
Project: CustomWorldGen   File: Rotations.java   Source Code and License Vote up 4 votes
public Rotations(NBTTagList nbt)
{
    this.x = nbt.getFloatAt(0);
    this.y = nbt.getFloatAt(1);
    this.z = nbt.getFloatAt(2);
}