From 707a5c35de8721229b359d1d10ced90c4d8eb81c Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Sun, 8 Oct 2023 17:10:42 +0300 Subject: [PATCH] BoughtFromTradingStationCriterion: Fix regression The "item" property in the JSON format was accidentally made required in the 1.20.2 update. --- .../criterion/BoughtFromTradingStationCriterion.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/common/src/main/kotlin/juuxel/adorn/criterion/BoughtFromTradingStationCriterion.kt b/common/src/main/kotlin/juuxel/adorn/criterion/BoughtFromTradingStationCriterion.kt index fd22ee8f9..258a603b9 100644 --- a/common/src/main/kotlin/juuxel/adorn/criterion/BoughtFromTradingStationCriterion.kt +++ b/common/src/main/kotlin/juuxel/adorn/criterion/BoughtFromTradingStationCriterion.kt @@ -1,7 +1,7 @@ package juuxel.adorn.criterion +import com.google.gson.JsonNull import com.google.gson.JsonObject -import com.google.gson.JsonParseException import net.minecraft.advancement.criterion.AbstractCriterion import net.minecraft.advancement.criterion.AbstractCriterionConditions import net.minecraft.item.ItemStack @@ -18,23 +18,21 @@ class BoughtFromTradingStationCriterion : AbstractCriterion, private val soldItem: ItemPredicate) : + class Conditions(playerPredicate: Optional, private val soldItem: ItemPredicate?) : AbstractCriterionConditions(playerPredicate) { fun matches(stack: ItemStack): Boolean = - soldItem.test(stack) + soldItem == null || soldItem.test(stack) override fun toJson(): JsonObject { val json = super.toJson() - json.add("sold_item", soldItem.toJson()) + json.add("sold_item", soldItem?.toJson() ?: JsonNull.INSTANCE) return json } }