From 28ea8e1daf0419a98056b364c44052a47ec1356c Mon Sep 17 00:00:00 2001 From: Luligabi1 <33578169+Luligabi1@users.noreply.github.com> Date: Wed, 1 Nov 2023 14:18:42 -0300 Subject: [PATCH] Use LibGUI's non-deprecated setInputFilter --- .../nathanpb/dml/screen/handler/LootFabricatorHandler.kt | 7 ++----- .../modular_armor/screen/MatterCondenserScreenHandler.kt | 4 ++-- .../dml/modular_armor/screen/ModularArmorScreenHandler.kt | 6 +----- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/LootFabricatorHandler.kt b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/LootFabricatorHandler.kt index 60ab7ed4..fad7bb7f 100644 --- a/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/LootFabricatorHandler.kt +++ b/base/src/main/kotlin/dev/nathanpb/dml/screen/handler/LootFabricatorHandler.kt @@ -20,10 +20,8 @@ package dev.nathanpb.dml.screen.handler -import dev.nathanpb.dml.MOD_ID import dev.nathanpb.dml.identifier import dev.nathanpb.dml.recipe.LootFabricatorRecipe -import dev.nathanpb.dml.screen.handler.slot.WTooltippedItemSlot import dev.nathanpb.dml.utils.RenderUtils import io.github.cottonmc.cotton.gui.SyncedGuiDescription import io.github.cottonmc.cotton.gui.widget.WBar @@ -35,7 +33,6 @@ import net.minecraft.entity.player.PlayerEntity import net.minecraft.entity.player.PlayerInventory import net.minecraft.inventory.SimpleInventory import net.minecraft.screen.ScreenHandlerContext -import net.minecraft.text.Text class LootFabricatorHandler( syncId: Int, @@ -53,7 +50,7 @@ class LootFabricatorHandler( setRootPanel(root) val inputSlot = WItemSlot(blockInventory, 0, 1, 1, false).apply { - setFilter { stack -> + setInputFilter { stack -> world.recipeManager.values().filterIsInstance() .any { it.input.test(stack) } } @@ -70,7 +67,7 @@ class LootFabricatorHandler( (0 until 9).forEach { val x = (it % 3) val y = (it / 3) - val slot = WItemSlot.of(blockInventory, it + 1).setFilter { false } + val slot = WItemSlot.of(blockInventory, it + 1).setInputFilter { false } root.add(slot, x + 5, y + 1) } diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/MatterCondenserScreenHandler.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/MatterCondenserScreenHandler.kt index 98b77a3d..a3872e2f 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/MatterCondenserScreenHandler.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/MatterCondenserScreenHandler.kt @@ -65,7 +65,7 @@ class MatterCondenserScreenHandler( val slots = WPlainPanel() val armorSlot = WTooltippedItemSlot.of(blockInventory, 0, true, Text.translatable("gui.${MOD_ID}.glitch_armor_only")).apply { - setFilter { + setInputFilter { it.item is ItemModularGlitchArmor && !ModularArmorData(it).tier().isMaxTier() } } @@ -74,7 +74,7 @@ class MatterCondenserScreenHandler( val matterSlots = (1..6).map { WItemSlot(blockInventory, it, 1, 1, false).apply { - setFilter { stack -> + setInputFilter { stack -> stack.item is ItemPristineMatter } diff --git a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/ModularArmorScreenHandler.kt b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/ModularArmorScreenHandler.kt index b539dc40..36f50e43 100644 --- a/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/ModularArmorScreenHandler.kt +++ b/modular-armor/src/main/kotlin/dev/nathanpb/dml/modular_armor/screen/ModularArmorScreenHandler.kt @@ -20,8 +20,6 @@ package dev.nathanpb.dml.modular_armor.screen -import com.sun.java.accessibility.util.SwingEventMonitor.addChangeListener -import dev.nathanpb.dml.MOD_ID import dev.nathanpb.dml.data.dataModel import dev.nathanpb.dml.identifier import dev.nathanpb.dml.item.ItemDataModel @@ -30,7 +28,6 @@ import dev.nathanpb.dml.modular_armor.core.ModularEffectRegistry import dev.nathanpb.dml.modular_armor.data.ModularArmorData import dev.nathanpb.dml.modular_armor.net.C2S_MODULAR_EFFECT_TOGGLE import dev.nathanpb.dml.screen.handler.registerScreenHandlerForItemStack -import dev.nathanpb.dml.screen.handler.slot.WTooltippedItemSlot import dev.nathanpb.dml.utils.RenderUtils import dev.nathanpb.dml.utils.takeOrNull import io.github.cottonmc.cotton.gui.SyncedGuiDescription @@ -46,7 +43,6 @@ import net.minecraft.inventory.SimpleInventory import net.minecraft.item.ItemStack import net.minecraft.network.PacketByteBuf import net.minecraft.screen.ArrayPropertyDelegate -import net.minecraft.text.Text import net.minecraft.util.Hand import net.minecraft.util.Identifier @@ -102,7 +98,7 @@ class ModularArmorScreenHandler( } val dataModelSlot = WItemSlot(blockInventory, 0, 1, 1, false).apply { - setFilter { + setInputFilter { it.isEmpty || ( (it.item as? ItemDataModel)?.category != null && data.tier().ordinal >= it.dataModel.tier().ordinal