generated from QuiltMC/quilt-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add search support for resource/data packs screens
- Loading branch information
Showing
23 changed files
with
323 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/generated/.cache/8b4ca9c9ab0815070c5c01187251210b1198b272
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// 1.20.1 2023-09-14T12:39:06.073621692 Searchable/Language (en_us) | ||
37d4d7775d43b425d020574f6d397748e2093ed2 assets/searchable/lang/en_us.json | ||
// 1.20.1 2023-09-17T16:26:09.415058591 Searchable/Language (en_us) | ||
46fba4b4e11e5664b2bdbb8be156734b474b0951 assets/searchable/lang/en_us.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/io/github/antikyth/searchable/mixin/pack/PackListWidgetMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package io.github.antikyth.searchable.mixin.pack; | ||
|
||
import io.github.antikyth.searchable.Searchable; | ||
import io.github.antikyth.searchable.config.SearchableConfig; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.pack.PackListWidget; | ||
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
|
||
@Mixin(PackListWidget.class) | ||
public class PackListWidgetMixin extends AlwaysSelectedEntryListWidget<PackListWidget.ResourcePackEntry> { | ||
@Unique | ||
private static final int TITLE_Y = 8; | ||
@Unique | ||
private static final int TEXT_HEIGHT = 8; | ||
@Unique | ||
private static final int DROP_INFO_PADDING = 20 - (TITLE_Y + TEXT_HEIGHT); | ||
@Unique | ||
private static final int SHIFT = 16 + TEXT_HEIGHT + DROP_INFO_PADDING; | ||
|
||
public PackListWidgetMixin(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) { | ||
super(minecraftClient, width, height, top, bottom, entryHeight); | ||
} | ||
|
||
@ModifyArg(method = "<init>", at = @At( | ||
value = "INVOKE", | ||
target = "net/minecraft/client/gui/widget/AlwaysSelectedEntryListWidget.<init> (Lnet/minecraft/client/MinecraftClient;IIIII)V", | ||
ordinal = 0 | ||
), index = 3) | ||
private static int adjustTopCoord(int top) { | ||
if (!enabled()) return top; | ||
|
||
Searchable.LOGGER.debug("moving select pack screen pack list down by " + SHIFT + "px..."); | ||
|
||
return top + SHIFT; | ||
} | ||
|
||
@Unique | ||
private static boolean enabled() { | ||
return SearchableConfig.INSTANCE.select_packs_screen.add_search.value(); | ||
} | ||
} |
Oops, something went wrong.