diff options
| author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2025-06-26 15:29:07 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-26 21:29:07 +0200 |
| commit | 4627064699a0211f23f659ff6a814e717ef6f53c (patch) | |
| tree | 715b8e5ab3663fd408f20b4aa8444d138527245e /src | |
| parent | e5ff77c47f2936c34699a56b1394c1b5c18964e8 (diff) | |
| download | Firmament-4627064699a0211f23f659ff6a814e717ef6f53c.tar.gz Firmament-4627064699a0211f23f659ff6a814e717ef6f53c.tar.bz2 Firmament-4627064699a0211f23f659ff6a814e717ef6f53c.zip | |
feat: Add screen type matching to Custom Screen Layouts (#177)
Diffstat (limited to 'src')
| -rw-r--r-- | src/texturePacks/java/moe/nea/firmament/features/texturepack/CustomScreenLayouts.kt | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/texturePacks/java/moe/nea/firmament/features/texturepack/CustomScreenLayouts.kt b/src/texturePacks/java/moe/nea/firmament/features/texturepack/CustomScreenLayouts.kt index a68fb2a..4785e90 100644 --- a/src/texturePacks/java/moe/nea/firmament/features/texturepack/CustomScreenLayouts.kt +++ b/src/texturePacks/java/moe/nea/firmament/features/texturepack/CustomScreenLayouts.kt @@ -8,6 +8,7 @@ import net.minecraft.client.gui.DrawContext import net.minecraft.client.gui.screen.Screen import net.minecraft.client.gui.screen.ingame.HandledScreen import net.minecraft.client.render.RenderLayer +import net.minecraft.registry.Registries import net.minecraft.resource.ResourceManager import net.minecraft.resource.SinglePreparationResourceReloader import net.minecraft.screen.slot.Slot @@ -49,11 +50,16 @@ object CustomScreenLayouts : SinglePreparationResourceReloader<List<CustomScreen @Serializable data class Preds( val label: StringMatcher, + @Serializable(with = IdentifierSerializer::class) + val screenType: Identifier? = null, ) { fun matches(screen: Screen): Boolean { // TODO: does this deserve the restriction to handled screen val s = screen as? HandledScreen<*>? ?: return false - return label.matches(s.title) + val typeMatches = screenType == null || s.screenHandler.type.equals(Registries.SCREEN_HANDLER + .get(screenType)); + + return label.matches(s.title) && typeMatches } } @@ -215,5 +221,4 @@ object CustomScreenLayouts : SinglePreparationResourceReloader<List<CustomScreen } } } - } |
