AlexModGuy / AlexsCaves

75 stars 38 forks source link

Performance: Make melting-down nuclear furnaces find nearby nuclear sirens instead of vice-versa #1106

Open ByThePowerOfScience opened 3 weeks ago

ByThePowerOfScience commented 3 weeks ago

https://github.com/AlexModGuy/AlexsCaves/blob/2e8fc8b4fab4502ec4dd558dfcc467abd74953bd/src/main/java/com/github/alexmodguy/alexscaves/server/block/blockentity/NuclearSirenBlockEntity.java#L70-L83

entity.getNearbyCriticalFurnaces((ServerLevel) level, 128).findAny() ends up being a fairly expensive process when run so frequently, with one nuclear siren on the server using roughly .38% of the total server time.

Since melting down happens less frequently than once per second, making the Siren a POI and having the Furnace find nearby Sirens to trigger would run the POI check less often.