public EntityManager(World World) { NextEntityId = 0; Entities = new List<Entity>(); this.World = World; }
public void AddWorld(World World) { World.EntityManager.Server = this; World.OnBlockChanged += HandleOnBlockChanged; Worlds.Add(World); }
public MinecraftClient[] GetClientsInWorld(World world) { List<MinecraftClient> clients = new List<MinecraftClient>(); foreach (var client in Clients) { if (world.EntityManager.Entities.Contains(client.Entity)) clients.Add(client); } return clients.ToArray(); }
/// <summary> /// Called when an action in the world causes this block to update. /// </summary> /// <param name="world">The world the update occured in</param> /// <param name="position">The location of the updated block</param> public virtual void BlockUpdate(World world, Vector3 position) { }
/// <summary> /// Called when this block is right clicked by a player. /// </summary> /// <param name="world">The world in which the event occured</param> /// <param name="position">The location of the block being clicked</param> /// <param name="clickedBy">The player who clicked the block</param> /// <returns>False to override the default action (block placement)</returns> public virtual bool BlockRightClicked(World world, Vector3 position, PlayerEntity clickedBy) { return true; }
/// <summary> /// Called when this block is destroyed /// </summary> /// <param name="world">The world the block used to exist in</param> /// <param name="position">The position the block used to occupy</param> /// <param name="destroyedBy">The entity that destroyed the block</param> public virtual void BlockDestroyed(World world, Vector3 position, Entity destroyedBy) { }
/// <summary> /// Called when this block is placed /// </summary> /// <param name="world">The world it was placed in</param> /// <param name="position">The position it was placed at</param> /// <param name="blockClicked">The location of the block left clicked upon placing</param> /// <param name="facing">The facing of the placement</param> /// <param name="placedBy">The entity who placed the block</param> /// <returns>False to override placement</returns> public virtual bool BlockPlaced(World world, Vector3 position, Vector3 blockClicked, byte facing, Entity placedBy) { return true; }
/// <summary> /// Called when this block is right clicked by a player. /// </summary> /// <param name="world">The world in which the event occured</param> /// <param name="position">The location of the block being clicked</param> /// <param name="clickedBy">The player who clicked the block</param> /// <returns>False to override the default action (block placement)</returns> /// <remarks></remarks> public override bool BlockRightClicked(World world, Vector3 position, PlayerEntity clickedBy) { return false; }