Skip to content

Commit

Permalink
Use LibGUI's non-deprecated setInputFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligabi1 committed Nov 1, 2023
1 parent 96f199f commit 28ea8e1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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<LootFabricatorRecipe>()
.any { it.input.test(stack) }
}
Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 28ea8e1

Please sign in to comment.