Archie Kearney

a mod that makes it so when you open the ui of a wander trader, in the top left coner of the trade menu there is a reroll button that resets their trades (only vanilla trades) it can also be rerolled by using a configurable keybind

Kodari AI
KodariOct 17 at 2:43 pm 3
WanderingTraderReroll
A Minecraft Fabric mod that adds a reroll button to the Wandering Trader's trade menu UI, positioned in the top-left corner. Clicking the button resets the trader's vanilla trades, generating a new random selection. The mod also supports a configurable keybind that triggers the same reroll functionality without opening the UI. The keybind can be customized through the mod's configuration file, allowing players to quickly refresh trades while interacting with the trader. The mod only affects vanilla Wandering Trader trades and does not interfere with other modded trade systems.
  1. Add the Fabric 26.3 project skeleton and mod metadata.

  2. Implement a trader-screen reroll button and configurable keybind using owo-ui for the overlay.

  3. Route rerolls to the server and regenerate only vanilla wandering-trader offers.

Added the Fabric 26.3 mod with an owo-ui reroll button on merchant screens and a default R keybind that players can remap in Controls. The server validates the open trade menu and rerolls offers only for a Wandering Trader, then updates the trade list immediately.

Archie Kearney

make the buttone like this

Kodari AI
KodariOct 19 at 1:13 pm 2

Replaced the Reroll text panel with a compact 20×20 vanilla-style cycle-arrow button, positioned near the top of the trade menu like the reference. Hovering shows Cycle Trades.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
Code
11 229
src/main/java/com/kodari/wandertradereroll/TraderRerollMod.java
package com.kodari.wandertradereroll;

import com.kodari.wandertradereroll.mixin.AbstractVillagerAccessor;
import com.kodari.wandertradereroll.mixin.MerchantMenuAccessor;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.npc.wanderingtrader.WanderingTrader;
import net.minecraft.world.inventory.MerchantMenu;
import net.minecraft.world.item.trading.Merchant;
import net.minecraft.world.item.trading.MerchantOffers;

public class TraderRerollMod implements ModInitializer {
    public static final String MOD_ID = "wandertradereroll";

    @Override
    public void onInitialize() {
        PayloadTypeRegistry.serverboundPlay().register(TraderRerollPayload.TYPE, TraderRerollPayload.CODEC);
        ServerPlayNetworking.registerGlobalReceiver(TraderRerollPayload.TYPE, TraderRerollMod::rerollOffers);
    }

    private static void rerollOffers(TraderRerollPayload payload, ServerPlayNetworking.Context context) {
        ServerPlayer player = context.player();
        if (!(player.containerMenu instanceof MerchantMenu menu))
            return;

        if (menu.containerId != payload.menuId() || !menu.stillValid(player))
            return;

        Merchant merchant = ((MerchantMenuAccessor) menu).kodari$getTrader();
        if (!(merchant instanceof WanderingTrader trader) || trader.getTradingPlayer() != player)
            return;

        ((AbstractVillagerAccessor) trader).kodari$setOffers(null);
        MerchantOffers offers = trader.getOffers();
        player.sendMerchantOffers(
                menu.containerId,
                offers,
                1,
                merchant.getVillagerXp(),
                merchant.showProgressBar(),
                merchant.canRestock()
        );
    }
}