public override void RemoveInvalidBlocks() { this._blockRefCount = 0; this._tickRefCount = 0; for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) { for (int z = 0; z < 16; z++) { var idx = GetCoordinateIndex(x, y, z); var blockstate = this.Get(x, y, z, 0);//.Block; if (blockstate == null) { continue; } var block = blockstate.Block; //TransparentBlocks.Set(idx, block.Transparent); // SolidBlocks.Set(idx, block.Solid); if (!(block is Air)) { ++this._blockRefCount; if (block.RandomTicked) { ++this._tickRefCount; } if (block.BlockMaterial.IsWatterLoggable) { Set(1, x, y, z, BlockFactory.GetBlockState("minecraft:water")); } } if (block.LightValue > 0) { var coords = new BlockCoordinates(x, y, z); if (!LightSources.Contains(coords)) { LightSources.Add(coords); } if (GetBlocklight(x, y, z) != block.LightValue) { SetBlocklight(x, y, z, (byte)block.LightValue); SetBlockLightScheduled(x, y, z, true); } } } } } }
public void RemoveInvalidBlocks() { this._blockRefCount = 0; this._tickRefCount = 0; for (int x = 0; x < 16; x++) { for (int y = 0; y < 16; y++) { for (int z = 0; z < 16; z++) { var idx = GetCoordinateIndex(x, y, z); //foreach (var state in this.GetAll(x, y, z)) { var block = this.Get(x, y, z, 0).Block; TransparentBlocks.Set(idx, block.Transparent); SolidBlocks.Set(idx, block.Solid); if (!(block is Air)) { ++this._blockRefCount; if (block.RandomTicked) { ++this._tickRefCount; } } if (Alex.ServerType == ServerType.Java) { if (block.LightValue > 0) { var coords = new BlockCoordinates(x, y, z); if (!LightSources.Contains(coords)) { LightSources.Add(coords); } if (GetBlocklight(x, y, z) != block.LightValue) { SetBlocklight(x, y, z, (byte)block.LightValue); SetBlockLightScheduled(x, y, z, true); } } } } } } } //CheckForSolidBorder(); }
public void Set(int storage, int x, int y, int z, BlockState state) { if (storage > _blockStorages.Length) { throw new IndexOutOfRangeException($"The storage id {storage} does not exist!"); } var blockCoordinates = new BlockCoordinates(x, y, z); if (state == null) { Log.Warn($"State == null"); return; } var coordsIndex = GetCoordinateIndex(x, y, z); if (storage == 0) { if (state.Block.LightValue > 0) { if (!LightSources.Contains(blockCoordinates)) { LightSources.Add(blockCoordinates); } SetBlocklight(x, y, z, (byte)state.Block.LightValue); SetBlockLightScheduled(x, y, z, true); } else { if (LightSources.Contains(blockCoordinates)) { LightSources.Remove(blockCoordinates); } } BlockState iblockstate = this.Get(x, y, z, storage); if (iblockstate != null) { Block block = iblockstate.Block; if (!(block is Air)) { --this._blockRefCount; if (block.RandomTicked) { --this._tickRefCount; } TransparentBlocks.Set(coordsIndex, true); SolidBlocks.Set(coordsIndex, false); } } OnBlockSet(x, y, z, state, iblockstate); } Block block1 = state.Block; if (storage == 0) { if (!(block1 is Air)) { ++this._blockRefCount; if (block1.RandomTicked) { ++this._tickRefCount; } TransparentBlocks.Set(coordsIndex, block1.Transparent); SolidBlocks.Set(coordsIndex, block1.Solid); } } if (state != null) { _blockStorages[storage].Set(x, y, z, state); } //ScheduledUpdates.Set(coordsIndex, true); SetScheduled(x, y, z, true); IsDirty = true; }