mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-22 16:48:25 +01:00
Update VV, validate namespace correctly in registry
This commit is contained in:
parent
458b4daf15
commit
2e0018b7bc
@ -14,7 +14,7 @@ maven_group=de.florianmichael
|
|||||||
archives_base_name=ViaFabricPlus
|
archives_base_name=ViaFabricPlus
|
||||||
|
|
||||||
# ViaVersion Libraries
|
# 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
|
viabackwards_version=5.0.0-20240515.152913-2
|
||||||
vialegacy_version=3.0.0-20240517.210413-2
|
vialegacy_version=3.0.0-20240517.210413-2
|
||||||
viaaprilfools_version=3.0.0-20240517.172611-2
|
viaaprilfools_version=3.0.0-20240517.172611-2
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package de.florianmichael.viafabricplus.fixes.versioned;
|
package de.florianmichael.viafabricplus.fixes.versioned;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.util.Key;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
import net.minecraft.enchantment.Enchantments;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -72,11 +72,11 @@ public class Enchantments1_14_4 {
|
|||||||
ENCHANTMENT_REGISTRY.put("vanishing_curse", Enchantments.VANISHING_CURSE);
|
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) {
|
if (identifier == null) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
return Optional.ofNullable(ENCHANTMENT_REGISTRY.get(identifier.getPath()));
|
return Optional.ofNullable(ENCHANTMENT_REGISTRY.get(Key.stripMinecraftNamespace(identifier)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -89,9 +89,9 @@ public abstract class MixinItemStack {
|
|||||||
final NbtList enchantments = nbt.getList(name, NbtElement.COMPOUND_TYPE);
|
final NbtList enchantments = nbt.getList(name, NbtElement.COMPOUND_TYPE);
|
||||||
for (NbtElement element : enchantments) {
|
for (NbtElement element : enchantments) {
|
||||||
final NbtCompound enchantment = (NbtCompound) element;
|
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 -> {
|
value.ifPresent(e -> {
|
||||||
final int lvl = enchantment.getInt("lvl");
|
final int lvl = enchantment.getInt("lvl");
|
||||||
tooltip.accept(e.getName(MathHelper.clamp(lvl, Short.MIN_VALUE, Short.MAX_VALUE)));
|
tooltip.accept(e.getName(MathHelper.clamp(lvl, Short.MIN_VALUE, Short.MAX_VALUE)));
|
||||||
|
Loading…
Reference in New Issue
Block a user