void HandleBlockChanged(object sender, BlockChangeEventArgs e) { // TODO: Propegate lighting changes to client (not possible with beta 1.7.3 protocol) if (e.NewBlock.ID != e.OldBlock.ID || e.NewBlock.Metadata != e.OldBlock.Metadata) { for (int i = 0, ClientsCount = Clients.Count; i < ClientsCount; i++) { var client = (RemoteClient)Clients[i]; // TODO: Confirm that the client knows of this block if (client.LoggedIn && client.World == sender) { client.QueuePacket(new BlockChangePacket(e.Position.X, (sbyte)e.Position.Y, e.Position.Z, (sbyte)e.NewBlock.ID, (sbyte)e.NewBlock.Metadata)); } } PendingBlockUpdates.Enqueue(new BlockUpdate { Coordinates = e.Position, World = sender as IWorld }); ProcessBlockUpdates(); if (Program.ServerConfiguration.EnableLighting) { var lighter = WorldLighters.SingleOrDefault(l => l.World == sender); if (lighter != null) { lighter.EnqueueOperation(new BoundingBox(e.Position, e.Position + Vector3.One), true); lighter.EnqueueOperation(new BoundingBox(e.Position, e.Position + Vector3.One), false); } } } }
void Game_Client_BlockChanged(object sender, BlockChangeEventArgs e) { WorldLighting.EnqueueOperation(new TrueCraft.API.BoundingBox( e.Position, e.Position + Coordinates3D.One), false); WorldLighting.EnqueueOperation(new TrueCraft.API.BoundingBox( e.Position, e.Position + Coordinates3D.One), true); var posA = e.Position; posA.Y = 0; var posB = e.Position; posB.Y = World.Height; posB.X++; posB.Z++; WorldLighting.EnqueueOperation(new TrueCraft.API.BoundingBox(posA, posB), true); WorldLighting.EnqueueOperation(new TrueCraft.API.BoundingBox(posA, posB), false); for (int i = 0; i < 100; i++) { if (!WorldLighting.TryLightNext()) break; } }
void HandleBlockChanged(object sender, BlockChangeEventArgs e) { for (int i = 0, ClientsCount = Clients.Count; i < ClientsCount; i++) { var client = (RemoteClient)Clients[i]; // TODO: Confirm that the client knows of this block if (client.LoggedIn && client.World == sender) { client.QueuePacket(new BlockChangePacket(e.Position.X, (sbyte)e.Position.Y, e.Position.Z, (sbyte)e.NewBlock.ID, (sbyte)e.NewBlock.Metadata)); } } PendingBlockUpdates.Enqueue(new BlockUpdate { Coordinates = e.Position, World = sender as IWorld }); ProcessBlockUpdates(); }
protected internal void OnBlockChanged(BlockChangeEventArgs e) { if (BlockChanged != null) BlockChanged(this, e); }