mirror of
https://github.com/GTNewHorizons/GTNHLib.git
synced 2026-11-08 12:34:52 +00:00
Fix position hash for random models (#381)
This commit is contained in:
1 parent
cab49dc8de
commit
32afd73ac8
2 files changed
+10
-5
No files matched your search
@@ -5,7 +5,6 @@ import static com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8.unpac
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8.unpackZ;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.DIRECTIONS;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.VALUES;
|
||||
import static com.gtnewhorizon.gtnhlib.util.CoordinatePacker.pack;
|
||||
import static java.lang.Float.intBitsToFloat;
|
||||
import static java.lang.Math.max;
|
||||
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.ENTITY;
|
||||
@@ -83,7 +82,7 @@ public class ModelISBRH implements ISimpleBlockRenderingHandler, IItemRenderer {
|
||||
var rendered = false;
|
||||
for (var dir : VALUES) {
|
||||
worldContext.quadFacing = dir;
|
||||
worldContext.random.setSeed(pack(x, y, z));
|
||||
worldContext.seedRNG(x, y, z);
|
||||
|
||||
final var quads = model.getQuads(worldContext);
|
||||
if (quads.isEmpty()) continue;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.gtnewhorizon.gtnhlib.client.model;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.util.CoordinatePacker.pack;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -39,7 +37,14 @@ public class WorldContext implements BakedModelQuadContext.World {
|
||||
this.z = z;
|
||||
this.blockState = BlockPropertyRegistry.getBlockState(world, x, y, z);
|
||||
this.random = random;
|
||||
random.setSeed(pack(x, y, z));
|
||||
seedRNG(x, y, z);
|
||||
}
|
||||
|
||||
/// Don't ask me why the magic numbers work, because I don't know. Something something hash function...
|
||||
public void seedRNG(int x, int y, int z) {
|
||||
long h = x * 3129871L ^ y * 116129781L ^ z;
|
||||
h = h * h * 42317861L + h * 11L;
|
||||
random.setSeed(h ^ (h >>> 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,4 +86,5 @@ public class WorldContext implements BakedModelQuadContext.World {
|
||||
public @Nullable Supplier<ModelQuadViewMutable> getQuadPool() {
|
||||
return quadPool;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user