mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-18 00:20:44 +00:00
Fix old potion exchanges
This commit is contained in:
@@ -84,7 +84,11 @@ public final class PotionModifier extends ModifierData {
|
||||
@Nonnull
|
||||
public static PotionModifier fromNBT(@Nonnull final NBTCompound nbt) {
|
||||
final var modifier = new PotionModifier();
|
||||
modifier.setPotionData(NBTEncodings.decodePotionData(nbt.getCompound(BASE_KEY)));
|
||||
PotionType type = NBTEncodings.decodePotionData(nbt.getCompound(BASE_KEY));
|
||||
if (type == null) {
|
||||
return null; // "UNCRAFTABLE" potion which is removed in 1.21
|
||||
}
|
||||
modifier.setPotionData(type);
|
||||
modifier.setEffects(Arrays.stream(nbt.getCompoundArray(EFFECTS_KEY))
|
||||
.map(NBTEncodings::decodePotionEffect)
|
||||
.collect(Collectors.toCollection(ArrayList::new)));
|
||||
|
||||
@@ -71,7 +71,11 @@ public final class NBTEncodings {
|
||||
if (nbt == null) {
|
||||
return null;
|
||||
}
|
||||
return PotionType.valueOf(nbt.getString(TYPE_KEY));
|
||||
String type = nbt.getString(TYPE_KEY);
|
||||
if ("UNCRAFTABLE".equals(type)) {
|
||||
return null;
|
||||
}
|
||||
return PotionType.valueOf(type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user