public void SetBlockState(int x, int y, int z, BlockState block, int storage, BlockUpdatePriority priority = BlockUpdatePriority.High | BlockUpdatePriority.Neighbors) { var chunkCoords = new ChunkCoordinates(x >> 4, z >> 4); ChunkColumn chunk; if (ChunkManager.TryGetChunk(chunkCoords, out chunk)) { var cx = x & 0xf; var cy = y & 0xff; var cz = z & 0xf; chunk.SetBlockState(cx, cy, cz, block, storage); EntityManager.RemoveBlockEntity(new BlockCoordinates(x, y, z)); var type = ScheduleType.Full; if ((priority & BlockUpdatePriority.Neighbors) != 0) { UpdateNeighbors(x, y, z); CheckForUpdate(chunkCoords, cx, cz); } if ((priority & BlockUpdatePriority.NoGraphic) != 0) { type |= ScheduleType.LowPriority; } //chunk.SetDirty(); //chunk.IsDirty = true; ChunkManager.ScheduleChunkUpdate(chunkCoords, type, (priority & BlockUpdatePriority.Priority) != 0); } }
public void SetBlockState(int x, int y, int z, BlockState block, int storage, BlockUpdatePriority priority = BlockUpdatePriority.High | BlockUpdatePriority.Neighbors) { var chunkCoords = new ChunkCoordinates(x >> 4, z >> 4); ChunkColumn chunk; if (ChunkManager.TryGetChunk(chunkCoords, out chunk)) { var cx = x & 0xf; var cy = y & 0xff; var cz = z & 0xf; //var previousBlock = chunk.GetBlockState(cx, cy, cz, storage); //if (block.Block.RequiresUpdate) { //block = block.Block.BlockPlaced(this, block, new BlockCoordinates(x,y,z)); } chunk.SetBlockState(cx, cy, cz, block, storage); EntityManager.RemoveBlockEntity(new BlockCoordinates(x, y, z)); var type = ScheduleType.Full; if ((priority & BlockUpdatePriority.Neighbors) != 0) { UpdateNeighbors(x, y, z); } if ((priority & BlockUpdatePriority.NoGraphic) != 0) { type |= ScheduleType.LowPriority; } var blockCoords = new BlockCoordinates(x, y, z); /*if (block.Block.BlockMaterial.BlocksLight) * { * SetBlockLight(blockCoords, 0); * } */ ChunkManager.SkyLightCalculator.Calculate(this, blockCoords); ChunkManager.BlockLightCalculations.Enqueue(blockCoords); //chunk.SetDirty(); //chunk.IsDirty = true; ChunkManager.ScheduleChunkUpdate(chunkCoords, type, (priority & BlockUpdatePriority.Priority) != 0); CheckForUpdate(chunkCoords, cx, cz); } }
private void CheckForUpdate(ChunkCoordinates chunkCoords, int cx, int cz) { if (cx == 0) { ChunkManager.ScheduleChunkUpdate(chunkCoords - new ChunkCoordinates(1, 0), ScheduleType.Border | ScheduleType.Lighting, true); } else if (cx == 0xf) { ChunkManager.ScheduleChunkUpdate(chunkCoords + new ChunkCoordinates(1, 0), ScheduleType.Border | ScheduleType.Lighting, true); } if (cz == 0) { ChunkManager.ScheduleChunkUpdate(chunkCoords - new ChunkCoordinates(0, 1), ScheduleType.Border | ScheduleType.Lighting, true); } else if (cz == 0xf) { ChunkManager.ScheduleChunkUpdate(chunkCoords + new ChunkCoordinates(0, 1), ScheduleType.Border | ScheduleType.Lighting, true); } }
public void SetBlockState(int x, int y, int z, IBlockState block) { var chunkCoords = new ChunkCoordinates(x >> 4, z >> 4); IChunkColumn chunk; if (ChunkManager.TryGetChunk(chunkCoords, out chunk)) { var cx = x & 0xf; var cy = y & 0xff; var cz = z & 0xf; chunk.SetBlockState(cx, cy, cz, block); UpdateNeighbors(x, y, z); CheckForUpdate(chunkCoords, cx, cz); ChunkManager.ScheduleChunkUpdate(chunkCoords, ScheduleType.Scheduled | ScheduleType.Lighting, true); } }
public void SetBlock(Block block) { var x = block.Coordinates.X; var y = block.Coordinates.Y; var z = block.Coordinates.Z; var chunkCoords = new ChunkCoordinates(x >> 4, z >> 4); IChunkColumn chunk; if (ChunkManager.TryGetChunk(chunkCoords, out chunk)) { var cx = x & 0xf; var cy = y & 0xff; var cz = z & 0xf; chunk.SetBlock(cx, cy, cz, block); ChunkManager.ScheduleChunkUpdate(new ChunkCoordinates(x >> 4, z >> 4), ScheduleType.Scheduled | ScheduleType.Lighting, true); UpdateNeighbors(x, y, z); CheckForUpdate(chunkCoords, cx, cz); } }
public void ChunkUpdate(IChunkColumn chunkColumn, ScheduleType type = ScheduleType.Lighting) { ChunkManager.ScheduleChunkUpdate(new ChunkCoordinates(chunkColumn.X, chunkColumn.Z), type); }