Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The vast majority of blocks an explosion of power ~4 tries to destroy are duplicates. The core of the block destroying part of this patch is to cache the block state, resistance, and whether it should explode - as those will not change. The other part of this patch is to optimise the visibility percentage calculation. The new visibility calculation takes advantage of the block caching already done by the explosion logic. It continues to update the cache as the visibility calculation uses many rays which can overlap significantly. Effectively, the patch uses a lot of caching to eliminate redundant operations. Performance benchmarking explosions is challenging, as it varies depending on the power, the number of nearby entities, and the nearby terrain. This means that no benchmark can cover all the cases. I decided to test a giant block of TNT, as that's where the optimisations would be needed the most. I tested using a 50x10x50 block of TNT above ground and determined the following: Vanilla time per explosion: 2.27ms Lithium time per explosion: 1.07ms This patch time per explosion: 0.45ms The results indicate that this logic is 5 times faster than Vanilla and 2.3 times faster than Lithium.
- Loading branch information