Skip to content

Commit

Permalink
Fix NeoForge mixin conflict
Browse files Browse the repository at this point in the history
Fixes #189
  • Loading branch information
Su5eD committed Jan 29, 2025
1 parent 4ea8954 commit cc242ef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,19 @@

package net.fabricmc.fabric.mixin.object.builder;

import java.util.stream.Stream;
import net.minecraft.core.DefaultedRegistry;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.npc.VillagerTrades;
import net.minecraft.world.entity.npc.VillagerType;
import net.minecraft.world.item.trading.ItemCost;
import net.minecraft.world.item.trading.MerchantOffer;
import com.llamalad7.mixinextras.sugar.Local;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(VillagerTrades.EmeraldsForVillagerTypeItem.class)
public abstract class TradeOffersTypeAwareBuyForOneEmeraldFactoryMixin {
/**
* Vanilla will check the "VillagerType -> Item" map in the stream and throw an exception for villager types not specified in the map.
* This breaks any and all custom villager types.
* We want to prevent this default logic so modded villager types will work.
* So we return an empty stream so an exception is never thrown.
*/
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/DefaultedRegistry;stream()Ljava/util/stream/Stream;"))
private <T> Stream<T> disableVanillaCheck(DefaultedRegistry<VillagerType> instance) {
return Stream.empty();
}

/**
* To prevent "item" -> "air" trades, if the result of a type aware trade is air, make sure no offer is created.
*/
Expand Down
4 changes: 2 additions & 2 deletions ffapi.gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
loom.platform=neoforge
fabric.loom.dontRemap=true

implementationVersion=2.0.22
implementationVersion=2.0.23

versionMc=1.21.1
versionForge=21.1.57
versionForge=21.1.115
versionForgifiedFabricLoader=2.5.29+0.16.0+1.21
versionFabricLoader=0.16.0

Expand Down

0 comments on commit cc242ef

Please sign in to comment.