Wine Rack

"Make a Fabric mod for Minecraft where Piglins accept Nether Quartz as a valid bartering currency, treating it exactly the same as gold ingots.

Kodari AI
KodariOct 30 at 7:56 am 1
QuartzBartering
A Fabric mod for Minecraft 1.21.11 that makes Piglins accept Nether Quartz as a valid bartering currency. When a player throws Nether Quartz near a Piglin, it triggers the same bartering behavior as gold ingots, including picking up the item, becoming temporarily hostile to non-gold holders, and dropping random bartering loot. The mod hooks into the Piglin's entity interaction logic, adding a custom check for Nether Quartz alongside the existing gold item check, ensuring seamless integration with vanilla bartering mechanics.
  1. Locate the exact vanilla Piglin bartering predicate and any related gold-only checks in Minecraft 1.21.11.

  2. Create the Fabric project files and a narrow mixin that adds Nether Quartz to the same currency check.

  3. Add the mixin configuration and mod metadata.

Created the quartzbarter Fabric mod. It adds Nether Quartz to Piglin’s shared barter-acceptance check, so Piglins can pick it up and barter it under the same conditions as gold ingots; gold bartering remains unchanged.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
6 109
src/main/java/com/kodari/quartzbarter/mixin/PiglinBrainMixin.java
package com.kodari.quartzbarter.mixin;

import net.minecraft.entity.mob.PiglinBrain;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
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.callback.CallbackInfoReturnable;

@Mixin(PiglinBrain.class)
public abstract class PiglinBrainMixin {
    @Inject(method = "acceptsForBarter", at = @At("HEAD"), cancellable = true)
    private static void quartzbarter$acceptQuartz(ItemStack stack, CallbackInfoReturnable<Boolean> cir) {
        if (stack.isOf(Items.QUARTZ)) {
            cir.setReturnValue(true);
        }
    }
}