9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-27 19:19:07 +00:00

Fixed Loot tables acting like a cucumber in the sun

- Fixed loot chests containing the exact same loot
- Fixed chests having nothing if a roll fails
- Fixed rolls always being done in the same order
- Added method to BlockPosition to get a unique long from 3 integers (x, y z)
This commit is contained in:
StrangeOne101
2021-07-05 04:24:13 +12:00
parent 3aa085f17e
commit 5103d91db0
6 changed files with 52 additions and 30 deletions

View File

@@ -11,6 +11,15 @@ public class BlockPosition
private int y;
private int z;
//Magic numbers
private static final int m1 = 1 + MathHelper.f(MathHelper.c(30000000));
private static final int m2 = 64 - (m1 * 2);
private static final long m3 = m1 + m2;
private static final long m4 = (1L << m1) - 1L;
private static final long m5 = (1L << m2) - 1L;
private static final long m6 = (1L << m1) - 1L;
public BlockPosition(int x, int y, int z)
{
this.x = x;
@@ -59,4 +68,16 @@ public class BlockPosition
{
return this.x == x && this.y == y && this.z == z;
}
public long asLong() {
return toLong(getX(), getY(), getZ());
}
public static long toLong(int x, int y, int z) {
long var3 = 0L;
var3 |= (x & m4) << m3;
var3 |= (y & m5) << 0L;
var3 |= (z & m6) << m2;
return var3;
}
}

View File

@@ -132,7 +132,7 @@ public class RNG extends Random
public int i(int lowerBound, int upperBound)
{
return (int) Math.round(d(lowerBound, upperBound));
return (int) Math.floor(d(lowerBound, upperBound));
}
public int i(int upperBound)
@@ -192,4 +192,8 @@ public class RNG extends Random
return pieces.get(nextInt(pieces.size()));
}
public long getSeed() {
return sx;
}
}