lithium-fabric icon indicating copy to clipboard operation
lithium-fabric copied to clipboard

new: optimize `BlockPos.iterateOutwards` by caching offsets

Open 2No2Name opened this issue 3 years ago • 1 comments

This PR implements the optimization from https://github.com/jellysquid3/lithium-fabric/pull/90 in a more generalized way, so that all calls to BlockPos.iterateOutwards can use cached values ( there are 31 different possible range parameters in vanilla only). Also this PR tries to implement the cache in a threadsafe manner.

This is currently a draft, because profiling still needs to be done.

2No2Name avatar Aug 31 '20 19:08 2No2Name

I don't think it makes sense to merge this. The worldgen code likely does not depend on the iteration order. In this case reordering the blockstate accesses makes sense. For Monsters searching for the nearest block, the block counting system could be used to cache the result until the monster moves or a block of the type appears or disappears.

2No2Name avatar Feb 04 '22 10:02 2No2Name