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(BlockCoordinates coordinates, BlockState blockState, int storage, BlockUpdatePriority priority = BlockUpdatePriority.High) { SetBlockState(coordinates.X, coordinates.Y, coordinates.Z, blockState, storage, priority); }
public void SetBlockState(int x, int y, int z, BlockState block, BlockUpdatePriority priority = BlockUpdatePriority.High) { SetBlockState(x, y, z, block, 0, priority); }
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); } }