Skip to content

Commit

Permalink
fix thread random stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Jan 1, 2024
1 parent 4e1bbe8 commit 4bac1be
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public final class SmithingRuneRecipe extends SmithingTrimRecipe { // Extends to
private final RuneColor runeColor;

private static Ingredient used;
private static final RandomSource BASE_INGREDIENT_RANDOM = RandomSource.create();
private static final RandomSource BASE_INGREDIENT_RANDOM = RandomSource.createThreadSafe();

private static ItemStack makeEnchantedDisplayItem(ItemStack input, RandomSource random) {
private static ItemStack makeEnchantedDisplayItem(ItemStack input) {
ItemStack stack = input.copy();
stack.hideTooltipPart(ItemStack.TooltipPart.ENCHANTMENTS);
stack.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
Expand All @@ -53,7 +53,7 @@ private static ItemStack makeEnchantedDisplayItem(ItemStack input, RandomSource
stack.enchant(Enchantments.UNBREAKING, 3); // it probably accepts unbreaking anyways
return stack;
}
return EnchantmentHelper.enchantItem(random, stack, 25, false);
return EnchantmentHelper.enchantItem(BASE_INGREDIENT_RANDOM, stack, 25, false);
}

private static Ingredient createBaseIngredient() {
Expand All @@ -70,7 +70,7 @@ private static Ingredient createBaseIngredient() {

used = Ingredient.of(displayItems
.filter(it -> !(it.getItem() instanceof IDisableable<?> dis) || dis.isEnabled())
.map(item -> makeEnchantedDisplayItem(item, BASE_INGREDIENT_RANDOM)));
.map(SmithingRuneRecipe::makeEnchantedDisplayItem));
}

return used;
Expand Down Expand Up @@ -108,7 +108,7 @@ public ItemStack assemble(Container container, @Nonnull RegistryAccess registry)
@Nonnull
@Override
public ItemStack getResultItem(@Nonnull RegistryAccess registry) {
ItemStack displayStack = makeEnchantedDisplayItem(new ItemStack(Items.IRON_CHESTPLATE), BASE_INGREDIENT_RANDOM);
ItemStack displayStack = makeEnchantedDisplayItem(new ItemStack(Items.IRON_CHESTPLATE));
ColorRunesModule.withRune(displayStack, runeColor);

return displayStack;
Expand Down

0 comments on commit 4bac1be

Please sign in to comment.