diff --git a/src/main/java/net/awakaxis/uno/mixin/WanderingTraderMixin.java b/src/main/java/net/awakaxis/uno/mixin/WanderingTraderMixin.java new file mode 100644 index 0000000..64a4869 --- /dev/null +++ b/src/main/java/net/awakaxis/uno/mixin/WanderingTraderMixin.java @@ -0,0 +1,34 @@ +package net.awakaxis.uno.mixin; + +import net.awakaxis.uno.UNOBlocks; +import net.awakaxis.uno.UNOItems; +import net.awakaxis.uno.item.UnoCardItem; +import net.minecraft.world.entity.npc.WanderingTrader; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.MerchantOffer; +import net.minecraft.world.item.trading.MerchantOffers; +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.CallbackInfo; + +@Mixin(WanderingTrader.class) +public abstract class WanderingTraderMixin { + + @Inject(method="updateTrades", at=@At("RETURN")) + private void appendUnoCard(CallbackInfo ci) { + WanderingTrader wanderingTrader = (WanderingTrader) (Object) this; + + MerchantOffers merchantOffers = wanderingTrader.getOffers(); + + MerchantOffer unoCardOffer = new MerchantOffer( + new ItemStack(Items.EMERALD, 15), + ItemStack.EMPTY, + UNOBlocks.CARD_DECK.asItem().getDefaultInstance(), + 1, 5, 0.05f + ); + + merchantOffers.add(unoCardOffer); + } +} diff --git a/src/main/resources/uno.mixins.json b/src/main/resources/uno.mixins.json index 8d599ac..3f7e45a 100644 --- a/src/main/resources/uno.mixins.json +++ b/src/main/resources/uno.mixins.json @@ -1,10 +1,11 @@ { - "required": true, - "package": "net.awakaxis.uno.mixin", - "compatibilityLevel": "JAVA_17", - "mixins": [ - ], - "injectors": { - "defaultRequire": 1 + "required": true, + "package": "net.awakaxis.uno.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "WanderingTraderMixin" + ], + "injectors": { + "defaultRequire": 1 } } \ No newline at end of file