private void UpdateLightSources() { var isPlaced = (Game1.currentLocation as DecoratableLocation)?.furniture.Contains(this) ?? false; foreach (var kv in LightSources.ToList()) { if (ItemProvider.Contains(kv.Key) && isPlaced && GlowConfig.ShowLights) { Game1.currentLightSources.Add(kv.Value); } else { LightSources.Remove(kv.Key); Game1.currentLightSources.Remove(kv.Value); } } }
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; }