Java Code Examples for net.minecraft.nbt.NBTTagList#func_150308_e()

The following examples show how to use net.minecraft.nbt.NBTTagList#func_150308_e() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchematicEntity.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void rotateLeft(IBuilderContext context) {
	NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6);
	Position pos = new Position(nbttaglist.func_150309_d(0),
			nbttaglist.func_150309_d(1), nbttaglist.func_150309_d(2));
	pos = context.rotatePositionLeft(pos);
	entityNBT.setTag("Pos",
			this.newDoubleNBTList(pos.x, pos.y, pos.z));

	nbttaglist = entityNBT.getTagList("Rotation", 5);
	float yaw = nbttaglist.func_150308_e(0);
	yaw += 90;
	entityNBT.setTag(
			"Rotation",
			this.newFloatNBTList(yaw,
					nbttaglist.func_150308_e(1)));
}
 
Example 2
Source File: Entity.java    From TickDynamic with MIT License 4 votes vote down vote up
/**
 * Reads the entity from NBT (calls an abstract helper method to read specialized data)
 */
public void readFromNBT(NBTTagCompound p_70020_1_)
{
    try
    {
        NBTTagList nbttaglist = p_70020_1_.getTagList("Pos", 6);
        NBTTagList nbttaglist1 = p_70020_1_.getTagList("Motion", 6);
        NBTTagList nbttaglist2 = p_70020_1_.getTagList("Rotation", 5);
        this.motionX = nbttaglist1.func_150309_d(0);
        this.motionY = nbttaglist1.func_150309_d(1);
        this.motionZ = nbttaglist1.func_150309_d(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.func_150309_d(0);
        this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.func_150309_d(1);
        this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.func_150309_d(2);
        this.prevRotationYaw = this.rotationYaw = nbttaglist2.func_150308_e(0);
        this.prevRotationPitch = this.rotationPitch = nbttaglist2.func_150308_e(1);
        this.fallDistance = p_70020_1_.getFloat("FallDistance");
        this.fire = p_70020_1_.getShort("Fire");
        this.setAir(p_70020_1_.getShort("Air"));
        this.onGround = p_70020_1_.getBoolean("OnGround");
        this.dimension = p_70020_1_.getInteger("Dimension");
        this.invulnerable = p_70020_1_.getBoolean("Invulnerable");
        this.timeUntilPortal = p_70020_1_.getInteger("PortalCooldown");

        if (p_70020_1_.hasKey("UUIDMost", 4) && p_70020_1_.hasKey("UUIDLeast", 4))
        {
            this.entityUniqueID = new UUID(p_70020_1_.getLong("UUIDMost"), p_70020_1_.getLong("UUIDLeast"));
        }

        this.setPosition(this.posX, this.posY, this.posZ);
        this.setRotation(this.rotationYaw, this.rotationPitch);
        if (p_70020_1_.hasKey("ForgeData"))
        {
            customEntityData = p_70020_1_.getCompoundTag("ForgeData");
        }

        for (String identifier : this.extendedProperties.keySet())
        {
            try
            {
                IExtendedEntityProperties props = this.extendedProperties.get(identifier);
                props.loadNBTData(p_70020_1_);
            }
            catch (Throwable t)
            {
                FMLLog.severe("Failed to load extended properties for %s.  This is a mod issue.", identifier);
                t.printStackTrace();
            }
        }

        //Rawr, legacy code, Vanilla added a UUID, keep this so older maps will convert properly
        if (p_70020_1_.hasKey("PersistentIDMSB") && p_70020_1_.hasKey("PersistentIDLSB"))
        {
            this.entityUniqueID = new UUID(p_70020_1_.getLong("PersistentIDMSB"), p_70020_1_.getLong("PersistentIDLSB"));
        }
        this.readEntityFromNBT(p_70020_1_);

        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 3
Source File: Rotations.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
public Rotations(NBTTagList nbt) {
	x = nbt.func_150308_e(0);
	y = nbt.func_150308_e(1);
	z = nbt.func_150308_e(2);
}