Skip to content

Commit 0c37d15

Browse files
committed
Cleanup 2
1 parent 989a375 commit 0c37d15

File tree

7 files changed

+13
-8
lines changed

7 files changed

+13
-8
lines changed

Common/src/main/java/at/petrak/hexcasting/api/mod/HexConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.world.item.Tier;
88
import net.minecraft.world.item.Tiers;
99
import net.minecraft.world.level.Level;
10+
import net.minecraft.util.RandomSource;
1011

1112
import java.util.List;
1213

@@ -79,7 +80,7 @@ public interface ServerConfigAccess {
7980

8081
double traderScrollChance();
8182

82-
List<String> getRandomLootHex(int randint);
83+
List<String> getRandomLootHex(RandomSource rand);
8384

8485
int DEFAULT_MAX_OP_COUNT = 100_000;
8586
int DEFAULT_MAX_SPELL_CIRCLE_LENGTH = 1024;

Common/src/main/java/at/petrak/hexcasting/common/items/storage/ItemScroll.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public ItemScroll(Properties pProperties, int blockSize) {
5757
this.blockSize = blockSize;
5858
}
5959

60+
// this produces a scroll that will load the correct pattern for your world once it ticks
6061
public static ItemStack withPerWorldPattern(ItemStack stack, String op_id) {
6162
Item item = stack.getItem();
6263
if (item instanceof ItemScroll)

Common/src/main/java/at/petrak/hexcasting/common/loot/AddHexToAncientCypherFunc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public AddHexToAncientCypherFunc(LootItemCondition[] lootItemConditions) {
3939
* This doesn't actually have any params so extract behaviour out for the benefit of forge
4040
*/
4141
public static ItemStack doStatic(ItemStack stack, RandomSource rand) {
42-
var fullHex = HexConfig.server().getRandomLootHex(rand.nextInt());
42+
var fullHex = HexConfig.server().getRandomLootHex(rand);
4343
var patsTag = new ListTag();
4444
// skip first element since it's the name, not a pattern
4545
for (var patString : fullHex.subList(1,fullHex.size())){

Common/src/main/java/at/petrak/hexcasting/mixin/MixinWanderingTrader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.spongepowered.asm.mixin.injection.Inject;
1818
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1919

20-
// Adds ancient scrolls to the wandering trader's pool of offers
20+
// Adds ancient scrolls to the wandering trader by replacing one of the 5 junk trades
2121
@Mixin(WanderingTrader.class)
2222
public class MixinWanderingTrader {
2323
@Inject(method = "updateTrades", at = @At("RETURN"))

Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import me.shedaniel.autoconfig.serializer.PartitioningSerializer;
1616
import net.minecraft.resources.ResourceKey;
1717
import net.minecraft.resources.ResourceLocation;
18+
import net.minecraft.util.RandomSource;
1819
import net.minecraft.util.Mth;
1920
import net.minecraft.world.level.Level;
2021

@@ -340,8 +341,8 @@ public double cypherChance() {
340341
return cypherChance;
341342
}
342343

343-
public List<String> getRandomLootHex(int randint) {
344-
var index = Mth.abs(randint) % this.lootHexList.size();
344+
public List<String> getRandomLootHex(RandomSource rand) {
345+
var index = rand.nextInt(this.lootHexList.size());
345346
return this.lootHexList.get(index);
346347
}
347348
}

Fabric/src/main/java/at/petrak/hexcasting/fabric/loot/FabricHexLootModJankery.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ public static void lootLoad(ResourceLocation id, Consumer<LootPool.Builder> addP
2929
if (id.equals(Blocks.AMETHYST_CLUSTER.getLootTable())) {
3030
addPool.accept(makeAmethystInjectPool());
3131
} else if (id.equals(RANDOM_SCROLL_TABLE)) {
32+
// -1 weight = guaranteed spawn
3233
addPool.accept(makeScrollAddPool(-1));
3334
} else if (id.equals(RANDOM_CYPHER_TABLE)) {
35+
// 1 chance = guaranteed spawn
3436
addPool.accept(makeCypherAddPool(1));
3537
}
3638

Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import net.minecraft.resources.ResourceLocation;
77
import net.minecraft.world.level.Level;
88
import net.minecraftforge.common.ForgeConfigSpec;
9-
import net.minecraft.util.Mth;
9+
import net.minecraft.util.RandomSource;
1010

1111
import java.util.List;
1212

@@ -250,8 +250,8 @@ public double traderScrollChance() {
250250
}
251251

252252
@Override
253-
public List<String> getRandomLootHex(int randint) {
254-
var index = Mth.abs(randint) % lootHexList.get().size();
253+
public List<String> getRandomLootHex(RandomSource rand) {
254+
var index = rand.nextInt(lootHexList.get().size());
255255
return lootHexList.get().get(index);
256256
}
257257

0 commit comments

Comments
 (0)