ReynaldoP RotoniJr

make a mod that makes every villager trades to 1 emerald for each, only applies to villagers who trade stuff for emerald, doesnt apply to villager trades who offer emeralds for stuff, like it only makes it so 1 emerald is needed for 1 emerald etc. 26.3

Kodari AI
KodariOct 14 at 7:07 am 3
EmeraldTradeSimplifier
Fabric mod that modifies villager trade costs, setting every trade that requires emeralds as payment to exactly 1 emerald per item. Only affects trades where villagers demand emeralds in exchange for goods; trades where villagers offer emeralds as payment remain unchanged. Works with all vanilla villager professions and custom trades, ensuring consistent pricing across the game world. Compatible with Minecraft 26.3 and Fabric API.

I’ll look up the villager trade classes in the 26.3 source before writing the mod.Plan:

  1. Gradle and Fabric metadata files (settings.gradle, gradle.properties, build.gradle, fabric.mod.json, mixin config).

  2. One mixin on MerchantOffer.getModifiedCostCount. Emerald costs read as 1 unless the trade’s result is emerald. This runs on the server and the client, so the displayed price and the payment deduction match.

The mod is written for Minecraft 26.3 (Fabric). Every villager trade that costs emeralds now costs 1 emerald. Trades that pay out emeralds are left alone.

  • Price fix: MerchantOfferMixin hooks MerchantOffer.getModifiedCostCount. When a cost is emerald and the trade’s result is not emerald, the cost returns 1. The displayed price and the emeralds taken on trade both use this method, so they match.

  • Files: settings.gradle, gradle.properties, build.gradle, fabric.mod.json, emeraldtrades.mixins.json, and MerchantOfferMixin.java.

  • Mixin path: The mixin is in common code, so it runs on both the server and the client.

The mod doesn’t check the entity type, so it also changes wandering trader trades that cost emeralds. I read “only applies to villagers who trade stuff for emerald” as being about trade direction. If you want only villagers affected, tell me and I’ll change it.

To get the jar: click Compile in the top bar (on phone, ⋮ → Compile Project), then click Compile in the window. When it succeeds, click Download on that build. No items or blocks were added, so survival needs nothing extra. Villagers keep their normal trades and only the emerald price changes.

ReynaldoP RotoniJr

make every villager price only 1

Kodari AI
KodariOct 14 at 7:27 am 1

Both cost fields need to change: getModifiedCostCount covers the first cost, and the second cost is read straight from ItemCost.count(), so it needs its own hook on the private MerchantOffer constructor.

Every villager trade now costs 1 of each item, for both cost slots. The mixin is updated in MerchantOfferMixin.java.

  • First cost: getModifiedCostCount always returns 1, so the price shown and the amount taken both use 1. Demand and gossip discounts no longer change the price.

  • Second cost: the private MerchantOffer constructor gets a hook that rebuilds both cost slots with a count of 1. The second cost is read directly from its count, so it needs this.

  • Trade direction: trades that pay out emeralds are included too, but they were already 1 emerald or more in the old version, so nothing else changes there.

I haven’t compiled it. Click Compile in the top bar (on phone, ⋮ → Compile Project), then Compile in the window, and download the jar when it finishes. There are no new items or blocks, so nothing new is needed for survival.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
6 110
src/main/java/com/example/emeraldtrades/mixin/MerchantOfferMixin.java
package com.example.emeraldtrades.mixin;

import java.util.Optional;
import net.minecraft.world.item.trading.ItemCost;
import net.minecraft.world.item.trading.MerchantOffer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(MerchantOffer.class)
public abstract class MerchantOfferMixin {
	@ModifyVariable(method = "<init>(Lnet/minecraft/world/item/trading/ItemCost;Ljava/util/Optional;Lnet/minecraft/world/item/ItemStack;IIZIIFI)V", at = @At("HEAD"), argsOnly = true, index = 1)
	private static ItemCost emeraldtrades$firstCostIsOne(ItemCost cost) {
		return new ItemCost(cost.item(), 1, cost.components());
	}

	@ModifyVariable(method = "<init>(Lnet/minecraft/world/item/trading/ItemCost;Ljava/util/Optional;Lnet/minecraft/world/item/ItemStack;IIZIIFI)V", at = @At("HEAD"), argsOnly = true, index = 2)
	private static Optional<ItemCost> emeraldtrades$secondCostIsOne(Optional<ItemCost> cost) {
		return cost.map(c -> new ItemCost(c.item(), 1, c.components()));
	}

	@Inject(method = "getModifiedCostCount", at = @At("HEAD"), cancellable = true)
	private void emeraldtrades$priceIsOne(ItemCost cost, CallbackInfoReturnable<Integer> cir) {
		cir.setReturnValue(1);
	}
}