Update VV, validate namespace correctly in registry

This commit is contained in:
FlorianMichael 2024-05-20 00:26:56 +02:00
parent 458b4daf15
commit 2e0018b7bc
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 6 additions and 6 deletions

View File

@ -14,7 +14,7 @@ maven_group=de.florianmichael
archives_base_name=ViaFabricPlus
# ViaVersion Libraries
viaversion_version=5.0.0-20240517.190711-8
viaversion_version=5.0.0-20240519.100112-11
viabackwards_version=5.0.0-20240515.152913-2
vialegacy_version=3.0.0-20240517.210413-2
viaaprilfools_version=3.0.0-20240517.172611-2

View File

@ -19,9 +19,9 @@
package de.florianmichael.viafabricplus.fixes.versioned;
import com.viaversion.viaversion.util.Key;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.util.Identifier;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.HashMap;
@ -72,11 +72,11 @@ public class Enchantments1_14_4 {
ENCHANTMENT_REGISTRY.put("vanishing_curse", Enchantments.VANISHING_CURSE);
}
public static Optional<Enchantment> getOrEmpty(final @Nullable Identifier identifier) {
public static Optional<Enchantment> getOrEmpty(final @Nullable String identifier) {
if (identifier == null) {
return Optional.empty();
}
return Optional.ofNullable(ENCHANTMENT_REGISTRY.get(identifier.getPath()));
return Optional.ofNullable(ENCHANTMENT_REGISTRY.get(Key.stripMinecraftNamespace(identifier)));
}
}

View File

@ -89,9 +89,9 @@ public abstract class MixinItemStack {
final NbtList enchantments = nbt.getList(name, NbtElement.COMPOUND_TYPE);
for (NbtElement element : enchantments) {
final NbtCompound enchantment = (NbtCompound) element;
final String id = enchantment.getString("id");
final Optional<Enchantment> value = Enchantments1_14_4.getOrEmpty(Identifier.tryParse(id));
final String id = enchantment.getString("id");
final Optional<Enchantment> value = Enchantments1_14_4.getOrEmpty(id);
value.ifPresent(e -> {
final int lvl = enchantment.getInt("lvl");
tooltip.accept(e.getName(MathHelper.clamp(lvl, Short.MIN_VALUE, Short.MAX_VALUE)));