Skip to content

Commit

Permalink
Cleanup 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Robotgiggle committed Dec 13, 2024
1 parent 989a375 commit 0c37d15
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -79,7 +80,7 @@ public interface ServerConfigAccess {

double traderScrollChance();

List<String> getRandomLootHex(int randint);
List<String> getRandomLootHex(RandomSource rand);

int DEFAULT_MAX_OP_COUNT = 100_000;
int DEFAULT_MAX_SPELL_CIRCLE_LENGTH = 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -340,8 +341,8 @@ public double cypherChance() {
return cypherChance;
}

public List<String> getRandomLootHex(int randint) {
var index = Mth.abs(randint) % this.lootHexList.size();
public List<String> getRandomLootHex(RandomSource rand) {
var index = rand.nextInt(this.lootHexList.size());
return this.lootHexList.get(index);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public static void lootLoad(ResourceLocation id, Consumer<LootPool.Builder> 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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -250,8 +250,8 @@ public double traderScrollChance() {
}

@Override
public List<String> getRandomLootHex(int randint) {
var index = Mth.abs(randint) % lootHexList.get().size();
public List<String> getRandomLootHex(RandomSource rand) {
var index = rand.nextInt(lootHexList.get().size());
return lootHexList.get().get(index);
}

Expand Down

0 comments on commit 0c37d15

Please sign in to comment.