diff --git a/Common/src/main/java/at/petrak/hexcasting/api/mod/HexConfig.java b/Common/src/main/java/at/petrak/hexcasting/api/mod/HexConfig.java index 57051706c..50ef99124 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/mod/HexConfig.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/mod/HexConfig.java @@ -7,6 +7,7 @@ import net.minecraft.world.item.Tier; import net.minecraft.world.item.Tiers; import net.minecraft.world.level.Level; +import net.minecraft.util.RandomSource; import java.util.List; @@ -79,7 +80,7 @@ public interface ServerConfigAccess { double traderScrollChance(); - List getRandomLootHex(int randint); + List getRandomLootHex(RandomSource rand); int DEFAULT_MAX_OP_COUNT = 100_000; int DEFAULT_MAX_SPELL_CIRCLE_LENGTH = 1024; diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/storage/ItemScroll.java b/Common/src/main/java/at/petrak/hexcasting/common/items/storage/ItemScroll.java index a2ce7538c..91a953735 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/storage/ItemScroll.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/storage/ItemScroll.java @@ -57,6 +57,7 @@ public ItemScroll(Properties pProperties, int blockSize) { this.blockSize = blockSize; } + // this produces a scroll that will load the correct pattern for your world once it ticks public static ItemStack withPerWorldPattern(ItemStack stack, String op_id) { Item item = stack.getItem(); if (item instanceof ItemScroll) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/loot/AddHexToAncientCypherFunc.java b/Common/src/main/java/at/petrak/hexcasting/common/loot/AddHexToAncientCypherFunc.java index cc080b686..3055d1020 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/loot/AddHexToAncientCypherFunc.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/loot/AddHexToAncientCypherFunc.java @@ -39,7 +39,7 @@ public AddHexToAncientCypherFunc(LootItemCondition[] lootItemConditions) { * This doesn't actually have any params so extract behaviour out for the benefit of forge */ public static ItemStack doStatic(ItemStack stack, RandomSource rand) { - var fullHex = HexConfig.server().getRandomLootHex(rand.nextInt()); + var fullHex = HexConfig.server().getRandomLootHex(rand); var patsTag = new ListTag(); // skip first element since it's the name, not a pattern for (var patString : fullHex.subList(1,fullHex.size())){ diff --git a/Common/src/main/java/at/petrak/hexcasting/mixin/MixinWanderingTrader.java b/Common/src/main/java/at/petrak/hexcasting/mixin/MixinWanderingTrader.java index be43d5b0c..6972090d5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/mixin/MixinWanderingTrader.java +++ b/Common/src/main/java/at/petrak/hexcasting/mixin/MixinWanderingTrader.java @@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -// Adds ancient scrolls to the wandering trader's pool of offers +// Adds ancient scrolls to the wandering trader by replacing one of the 5 junk trades @Mixin(WanderingTrader.class) public class MixinWanderingTrader { @Inject(method = "updateTrades", at = @At("RETURN")) diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java index a4e263949..0b5bc2766 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java @@ -15,6 +15,7 @@ import me.shedaniel.autoconfig.serializer.PartitioningSerializer; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.RandomSource; import net.minecraft.util.Mth; import net.minecraft.world.level.Level; @@ -340,8 +341,8 @@ public double cypherChance() { return cypherChance; } - public List getRandomLootHex(int randint) { - var index = Mth.abs(randint) % this.lootHexList.size(); + public List getRandomLootHex(RandomSource rand) { + var index = rand.nextInt(this.lootHexList.size()); return this.lootHexList.get(index); } } diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/loot/FabricHexLootModJankery.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/loot/FabricHexLootModJankery.java index 4389a094e..2cc402058 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/loot/FabricHexLootModJankery.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/loot/FabricHexLootModJankery.java @@ -29,8 +29,10 @@ public static void lootLoad(ResourceLocation id, Consumer addP if (id.equals(Blocks.AMETHYST_CLUSTER.getLootTable())) { addPool.accept(makeAmethystInjectPool()); } else if (id.equals(RANDOM_SCROLL_TABLE)) { + // -1 weight = guaranteed spawn addPool.accept(makeScrollAddPool(-1)); } else if (id.equals(RANDOM_CYPHER_TABLE)) { + // 1 chance = guaranteed spawn addPool.accept(makeCypherAddPool(1)); } diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexConfig.java b/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexConfig.java index a5726ff34..70d46b1cb 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexConfig.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexConfig.java @@ -6,7 +6,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.Level; import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; import java.util.List; @@ -250,8 +250,8 @@ public double traderScrollChance() { } @Override - public List getRandomLootHex(int randint) { - var index = Mth.abs(randint) % lootHexList.get().size(); + public List getRandomLootHex(RandomSource rand) { + var index = rand.nextInt(lootHexList.get().size()); return lootHexList.get().get(index); }