From 91ec3222a406349733230877bf87e9cafa00dff1 Mon Sep 17 00:00:00 2001 From: LimonBlaze <1195384759@qq.com> Date: Sun, 17 Apr 2022 19:19:31 +0800 Subject: [PATCH] Fixed nullability problem #2 --- gradle.properties | 2 +- .../limonblaze/originsclasses/mixin/PotionUtilMixin.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 98e152f..603d098 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ org.gradle.daemon=false mappings_version=2022.03.13-1.18.2 # Mod Properties - mod_version=1.1.1 + mod_version=1.1.1.1 mod_id=origins_classes mod_author=LimonBlaze maven_group=limonblaze.originsclasses diff --git a/src/main/java/limonblaze/originsclasses/mixin/PotionUtilMixin.java b/src/main/java/limonblaze/originsclasses/mixin/PotionUtilMixin.java index 9d64dc8..6359cb0 100644 --- a/src/main/java/limonblaze/originsclasses/mixin/PotionUtilMixin.java +++ b/src/main/java/limonblaze/originsclasses/mixin/PotionUtilMixin.java @@ -18,9 +18,11 @@ public class PotionUtilMixin { @Inject(method = "getAllEffects(Lnet/minecraft/nbt/CompoundTag;)Ljava/util/List;", at = @At("RETURN"), cancellable = true) private static void originsClasses$modifyPotion(@Nullable CompoundTag nbt, CallbackInfoReturnable> cir) { - byte bonusLevel = ClericUtils.getPotionBonus(nbt); - if(bonusLevel > 0) { - cir.setReturnValue(cir.getReturnValue().stream().map(effect -> ClericUtils.applyPotionBonus(effect, bonusLevel)).collect(Collectors.toList())); + if(nbt != null) { + byte bonusLevel = ClericUtils.getPotionBonus(nbt); + if(bonusLevel > 0) { + cir.setReturnValue(cir.getReturnValue().stream().map(effect -> ClericUtils.applyPotionBonus(effect, bonusLevel)).collect(Collectors.toList())); + } } }