Ejemplo n.º 1
0
        /// <summary>
        /// Builds and spawns an EntityItem from a provided ItemStack.
        /// </summary>
        /// <param name="itemstack">The contents of the EntityItem</param>
        /// <param name="position">The position of the EntityItem</param>
        /// <param name="velocity">The velocity of the EntityItem</param>
        /// <param name="world">The world the EntityItems preside in.</param>
        /// <returns>A freshly baked EntityItem to introduce to the world.</returns>
        public static EntityItem FromItemstack(ItemStack itemstack, Vec3d position, Vec3d velocity, IWorldAccessor world)
        {
            EntityItem item = new EntityItem();

            item.Code            = GlobalConstants.EntityItemTypeCode;
            item.SimulationRange = (int)(0.75f * GlobalConstants.DefaultTrackingRange);
            item.Itemstack       = itemstack;

            item.ServerPos.SetPos(position);

            if (velocity == null)
            {
                velocity = new Vec3d((float)world.Rand.NextDouble() * 0.1f - 0.05f, (float)world.Rand.NextDouble() * 0.1f - 0.05f, (float)world.Rand.NextDouble() * 0.1f - 0.05f);
            }

            item.ServerPos.Motion = velocity;


            item.Pos.SetFrom(item.ServerPos);

            return(item);
        }
Ejemplo n.º 2
0
 public EntityItemSlot(EntityItem ei)
 {
     this.Ei = ei;
 }