From 7985cbb61b3939e4d080956131f7a988f4f030a7 Mon Sep 17 00:00:00 2001 From: tterrag1098 Date: Thu, 21 May 2015 01:38:05 -0400 Subject: [PATCH] Improve r* algorithm, and fix r16 --- .../chisel/api/rendering/TextureType.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cricketcraft/chisel/api/rendering/TextureType.java b/src/main/java/com/cricketcraft/chisel/api/rendering/TextureType.java index 91280423..04b83721 100644 --- a/src/main/java/com/cricketcraft/chisel/api/rendering/TextureType.java +++ b/src/main/java/com/cricketcraft/chisel/api/rendering/TextureType.java @@ -220,6 +220,11 @@ public enum TextureType { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { return V9.getIcon(variation, cachedObject, side, meta); } + + @Override + protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) { + return getRIcon(this, (TextureSubmap) cachedObject, x, y, z, side); + } }, R9("r9"){ @Override @@ -295,12 +300,19 @@ public enum TextureType { } protected static IIcon getRIcon(TextureType type, TextureSubmap map, int x, int y, int z, int side) { - rand.setSeed(x + y + z + side); + rand.setSeed(getCoordinateRandom(x, y, z)); rand.nextBoolean(); - int size = type == TextureType.R4 ? 2 : 3; + int size = type == TextureType.R4 ? 2 : type == TextureType.R9 ? 3 : 4; return map.getSubIcon(rand.nextInt(size), rand.nextInt(size)); } + private static long getCoordinateRandom(int x, int y, int z) { + // MC 1.8 code... + long l = (x * 3129871) ^ z * 116129781L ^ y; + l = l * l * 42317861L + l * 11L; + return l; + } + /* End of that mess */ private static final TextureType[] VALUES;