diff --git a/src/main/java/xyz/bluspring/kilt/forgeinjects/resources/ResourceKeyInject.java b/src/main/java/xyz/bluspring/kilt/forgeinjects/resources/ResourceKeyInject.java new file mode 100644 index 00000000..3cfebb1a --- /dev/null +++ b/src/main/java/xyz/bluspring/kilt/forgeinjects/resources/ResourceKeyInject.java @@ -0,0 +1,34 @@ +package xyz.bluspring.kilt.forgeinjects.resources; + +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(ResourceKey.class) +public abstract class ResourceKeyInject implements Comparable> { + @Shadow public abstract ResourceLocation location(); + + @Shadow public abstract ResourceLocation registry(); + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + + if (obj == null || this.getClass() != obj.getClass()) + return false; + + return this.location().equals(((ResourceKey) obj).location()) && this.registry().equals(((ResourceKey) obj).registry()); + } + + @Override + public int compareTo(@NotNull ResourceKey o) { + int ret = this.registry().compareTo(o.registry()); + if (ret == 0) + ret = this.location().compareTo(o.location()); + + return ret; + } +} diff --git a/src/main/resources/kilt_forge_injects.mixins.json b/src/main/resources/kilt_forge_injects.mixins.json index 1a7e9532..6b3e8c6b 100644 --- a/src/main/resources/kilt_forge_injects.mixins.json +++ b/src/main/resources/kilt_forge_injects.mixins.json @@ -56,6 +56,7 @@ "network.protocol.status.ServerStatusInject", "network.syncher.EntityDataSerializersInject", "resources.HolderSetCodecInject", + "resources.ResourceKeyInject", "resources.ResourceLocationInject", "server.BootstrapInject", "server.MinecraftServerInject",