示例#1
0
        public Entity(World world, CompoundTag tag)
        {
            this.EntityID = ++Entity.nextEntityId;

            this.SetDataProperty(new EntityDataLong(Entity.DATA_FLAGS, 0));
            this.SetDataProperty(new EntityDataShort(Entity.DATA_AIR, 400));
            this.SetDataProperty(new EntityDataShort(Entity.DATA_MAX_AIR, 400));
            this.SetDataProperty(new EntityDataString(Entity.DATA_NAMETAG, ""));
            this.SetDataProperty(new EntityDataLong(Entity.DATA_LEAD_HOLDER_EID, -1));
            this.SetDataProperty(new EntityDataFloat(Entity.DATA_SCALE, 1.0f));
            this.SetDataProperty(new EntityDataFloat(Entity.DATA_BOUNDING_BOX_WIDTH, this.WIDTH));
            this.SetDataProperty(new EntityDataFloat(Entity.DATA_BOUNDING_BOX_HEIGHT, this.HEIGHT));

            this.SetFlag(Entity.DATA_FLAGS, Entity.DATA_FLAG_HAS_COLLISION);
            this.SetFlag(Entity.DATA_FLAGS, Entity.DATA_FLAG_AFFECTED_BY_GRAVITY);

            if (!this.IsPlayer)
            {
                ListTag pos = tag.GetList("Pos");
                this.Vector3 = new Vector3(
                    pos.GetTag <FloatTag>(0).Data,
                    pos.GetTag <FloatTag>(1).Data,
                    pos.GetTag <FloatTag>(2).Data);
                ListTag rotation = tag.GetList("Rotation");
                this.Yaw   = pos.GetTag <FloatTag>(0).Data;
                this.Pitch = pos.GetTag <FloatTag>(1).Data;

                this.World = world;
                this.World.AddEntity(this);
            }

            this.EntityInit();
        }