Beispiel #1
0
func (mob *Mob) ReadNbt(tag nbt.ITag) (err os.Error) {
	if err = mob.PointObject.ReadNbt(tag); err != nil {
		return
	}

	if mob.look, err = nbtutil.ReadLookDegrees(tag, "Rotation"); err != nil {
		return
	}

	// TODO
	_ = tag.Lookup("FallDistance").(*nbt.Float).Value
	_ = tag.Lookup("Air").(*nbt.Short).Value
	_ = tag.Lookup("Fire").(*nbt.Short).Value

	return nil
}
Beispiel #2
0
func (mob *Mob) UnmarshalNbt(tag nbt.Compound) (err error) {
	if err = mob.PointObject.UnmarshalNbt(tag); err != nil {
		return
	}

	if mob.look, err = nbtutil.ReadLookDegrees(tag, "Rotation"); err != nil {
		return
	}

	// TODO
	_ = tag.Lookup("Air").(*nbt.Short).Value
	_ = tag.Lookup("AttackTime").(*nbt.Short).Value
	_ = tag.Lookup("DeathTime").(*nbt.Short).Value
	_ = tag.Lookup("FallDistance").(*nbt.Float).Value
	_ = tag.Lookup("Fire").(*nbt.Short).Value
	_ = tag.Lookup("Health").(*nbt.Short).Value
	_ = tag.Lookup("HurtTime").(*nbt.Short).Value

	return nil
}
Beispiel #3
0
// UnmarshalNbt unpacks the player data from their persistantly stored NBT
// data. It must only be called before Player.Run().
func (player *Player) UnmarshalNbt(tag *nbt.Compound) (err error) {
	if player.position, err = nbtutil.ReadAbsXyz(tag, "Pos"); err != nil {
		return
	}

	if player.look, err = nbtutil.ReadLookDegrees(tag, "Rotation"); err != nil {
		return
	}

	health, err := nbtutil.ReadShort(tag, "Health")
	if err != nil {
		return
	}
	player.health = Health(health)

	if err = player.inventory.UnmarshalNbt(tag.Lookup("Inventory")); err != nil {
		return
	}

	if player.onGround, err = nbtutil.ReadByte(tag, "OnGround"); err != nil {
		return
	}

	if player.dimension, err = nbtutil.ReadInt(tag, "Dimension"); err != nil {
		return
	}

	if player.sleeping, err = nbtutil.ReadByte(tag, "Sleeping"); err != nil {
		return
	}

	if player.fallDistance, err = nbtutil.ReadFloat(tag, "FallDistance"); err != nil {
		return
	}

	if player.sleepTimer, err = nbtutil.ReadShort(tag, "SleepTimer"); err != nil {
		return
	}

	if player.attackTime, err = nbtutil.ReadShort(tag, "AttackTime"); err != nil {
		return
	}

	if player.deathTime, err = nbtutil.ReadShort(tag, "DeathTime"); err != nil {
		return
	}

	if player.motion, err = nbtutil.ReadAbsVelocity(tag, "Motion"); err != nil {
		return
	}

	if player.hurtTime, err = nbtutil.ReadShort(tag, "HurtTime"); err != nil {
		return
	}

	if player.air, err = nbtutil.ReadShort(tag, "Air"); err != nil {
		return
	}

	if player.fire, err = nbtutil.ReadShort(tag, "Fire"); err != nil {
		return
	}

	return nil
}