Optimise BiomeManager#getFiddle
The floorMod and subtraction by 0.5 can be done before converting to double, and the division by 1024 may be converted to a simple multiplication. At this point, the result is exactly the same. However, to remove the extra multiplication by 0.9, it can be moved into the multiplication by 1/1024. This may affect the result to one ULP, but I do not forsee that causing any problems.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package ca.spottedleaf.moonrise.mixin.random_ticking;
|
||||
|
||||
import net.minecraft.world.level.biome.BiomeManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
@Mixin(BiomeManager.class)
|
||||
abstract class BiomeManagerMixin {
|
||||
|
||||
/**
|
||||
* @reason Replace floorMod and double division to optimise the function
|
||||
* @author Spottedleaf
|
||||
*/
|
||||
@Overwrite
|
||||
public static double getFiddle(final long seed) {
|
||||
return (double)(((seed >> 24) & (1024 - 1)) - (1024/2)) * (0.9 / 1024.0);
|
||||
}
|
||||
}
|
||||
@@ -91,6 +91,7 @@
|
||||
"poi_lookup.AcquirePoiMixin",
|
||||
"poi_lookup.PoiManagerMixin",
|
||||
"poi_lookup.PortalForcerMixin",
|
||||
"random_ticking.BiomeManagerMixin",
|
||||
"random_ticking.BiomeMixin",
|
||||
"random_ticking.LevelMixin",
|
||||
"random_ticking.ServerLevelMixin",
|
||||
|
||||
Reference in New Issue
Block a user