diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-07-06 20:38:11 +1000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-07-06 20:38:11 +1000 |
commit | 21d918ebc34c24e4044423f393ecb3f1be4fd249 (patch) | |
tree | 971ffed6f3431488299b53d313f184b7d71073b2 /src | |
parent | 6f3593f3d510458eaec3e97fa770b4d2a3cb241d (diff) | |
download | GT5-Unofficial-21d918ebc34c24e4044423f393ecb3f1be4fd249.tar.gz GT5-Unofficial-21d918ebc34c24e4044423f393ecb3f1be4fd249.tar.bz2 GT5-Unofficial-21d918ebc34c24e4044423f393ecb3f1be4fd249.zip |
$ Fixed an error in XSTR.java where the maximum bound for nextInt(x) could be 0.
$ Fixed some Aboriginal Trader Logic.
Diffstat (limited to 'src')
-rw-r--r-- | src/Java/gtPlusPlus/api/objects/random/XSTR.java | 11 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java | 33 |
2 files changed, 25 insertions, 19 deletions
diff --git a/src/Java/gtPlusPlus/api/objects/random/XSTR.java b/src/Java/gtPlusPlus/api/objects/random/XSTR.java index 7f83df52c4..4b5b1298b6 100644 --- a/src/Java/gtPlusPlus/api/objects/random/XSTR.java +++ b/src/Java/gtPlusPlus/api/objects/random/XSTR.java @@ -213,9 +213,14 @@ public class XSTR extends Random { */ @Override public int nextInt(final int bound) { - //if (bound <= 0) { + final int newBound; + if (bound <= 0) { + newBound = 1; //throw new RuntimeException("BadBound"); - //} + } + else { + newBound = bound; + } /*int r = next(31); int m = bound - 1; @@ -234,7 +239,7 @@ public class XSTR extends Random { this.last ^= (this.last >>> 35); this.last ^= (this.last << 4); this.seed = this.last; - final int out = (int) this.last % bound; + final int out = (int) this.last % newBound; return (out < 0) ? -out : out; } @Override diff --git a/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java b/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java index ef67543f47..b4b24bd779 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java +++ b/src/Java/gtPlusPlus/plugin/villagers/trade/TradeHandlerAboriginal.java @@ -74,21 +74,21 @@ public class TradeHandlerAboriginal extends TradeHandlerBase { init(); } if (initialised) { - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.wooden_door, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.log, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.log2, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.planks, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.sapling, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.sandstone, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.nether_brick, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.bookshelf, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.crafting_table, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.gravel, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.hardened_clay, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.cactus, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.quartz_block, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.stone, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); - recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.mossy_cobblestone, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(0, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.wooden_door, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.log, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.log2, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.planks, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.sapling, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.sandstone, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.nether_brick, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.bookshelf, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.crafting_table, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.gravel, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.hardened_clay, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.cactus, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.quartz_block, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.stone, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); + recipeList.add(new MerchantRecipe(ItemUtils.getSimpleStack(Blocks.mossy_cobblestone, Math.max(MathUtils.randInt(1, 64), MathUtils.randInt(1, 32))), getOutput())); shuffle(recipeList); shuffle(recipeList); shuffle(recipeList); @@ -98,9 +98,10 @@ public class TradeHandlerAboriginal extends TradeHandlerBase { } } + final static int MID_BOUND = 9; private ItemStack getOutput() { ItemStack output = mOutputs.get(MathUtils.randInt(0, mOutputs.size()-1)); - int outputSize = (output.stackSize == 0 ? (MathUtils.randInt(MathUtils.randInt(0, 8), MathUtils.randInt(4, 32))) : output.stackSize); + int outputSize = (output.stackSize == 0 ? (Math.min(MathUtils.randInt(MathUtils.randInt(1, MID_BOUND), MathUtils.randInt(MID_BOUND, 32)), MathUtils.randInt(MathUtils.randInt(5, MID_BOUND), MathUtils.randInt(MID_BOUND, 48)))) : output.stackSize); return ItemUtils.getSimpleStack(output, outputSize); } |