Throw the exception when a duplicate registry entry is found. (#3991)

* Actually throw the exception when a duplicate registry entry is found.

* Improve mixin
This commit is contained in:
modmuss 2024-08-04 13:53:18 +01:00 committed by GitHub
parent 176f90366d
commit 66911b8fa5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,6 +25,7 @@ import java.util.Set;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.mojang.serialization.Lifecycle;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
@ -379,4 +380,10 @@ public abstract class SimpleRegistryMixin<T> implements MutableRegistry<T>, Rema
fabric_prevEntries = null;
}
}
// Actually throw the exception when a duplicate is found.
@ModifyExpressionValue(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Util;throwOrPause(Ljava/lang/Throwable;)Ljava/lang/Throwable;"))
private <E extends Throwable> E throwOnDuplicate(E t) throws E {
throw t;
}
}