Skip to content

Commit 925ed8b

Browse files
committed
backport to 1.14.4
1 parent ca73e06 commit 925ed8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+729
-628
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Changes
2+
- Rewritten for 1.14.4
3+
- Fixed config saving bug

build.gradle

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
plugins {
2-
id 'dev.architectury.loom' version '1.6-SNAPSHOT' apply false
2+
id 'dev.architectury.loom' version '1.7-SNAPSHOT' apply false
33
id 'architectury-plugin' version '3.4-SNAPSHOT'
44
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
55
id "me.shedaniel.unified-publishing" version "0.1.+"
6+
id "com.github.breadmoirai.github-release" version "2.5.2"
67
}
78

89
architectury {
@@ -40,12 +41,12 @@ subprojects {
4041
// If you remove this line, sources will not be generated.
4142
withSourcesJar()
4243

43-
sourceCompatibility = JavaVersion.VERSION_21
44-
targetCompatibility = JavaVersion.VERSION_21
44+
sourceCompatibility = JavaVersion.VERSION_17
45+
targetCompatibility = JavaVersion.VERSION_17
4546
}
4647

4748
tasks.withType(JavaCompile).configureEach {
48-
it.options.release = 21
49+
it.options.release = 17
4950
}
5051

5152
// Configure Maven publishing.
@@ -66,3 +67,27 @@ subprojects {
6667
}
6768
}
6869
}
70+
71+
githubRelease {
72+
owner = "Boxadactle"
73+
repo = "BoxLib"
74+
tagName = "$project.version"
75+
targetCommitish = "latest"
76+
releaseName = "BoxLib $project.version"
77+
generateReleaseNotes = true
78+
body = """BoxLib $project.version for Minecraft $project.minecraft_version
79+
80+
${new File(rootProject.rootDir, project.changelog_file).text}
81+
"""
82+
authorization = "Token ${System.getenv("GITHUB_TOKEN")}"
83+
84+
var files = []
85+
for (String platform : project.enabled_platforms.split(',')) {
86+
files += fileTree("$platform/build/libs") {
87+
include "*$project.version*"
88+
}
89+
}
90+
releaseAssets = files
91+
92+
// dryRun = true
93+
}
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
package dev.boxadactle.debugkeybind;
22

3-
import dev.boxadactle.boxlib.command.BCommandManager;
43
import dev.boxadactle.boxlib.config.BConfigClass;
54
import dev.boxadactle.boxlib.config.BConfigHandler;
65
import dev.boxadactle.boxlib.util.ModLogger;
7-
import dev.boxadactle.debugkeybind.command.F3Command;
86
import dev.boxadactle.debugkeybind.keybind.KeybindConfig;
9-
import net.minecraft.client.KeyMapping;
7+
import net.minecraft.client.resources.language.I18n;
108

119
public class DebugKeybindMain {
1210
public static final String MOD_NAME = "DebugKeybind";
1311

1412
public static final String MOD_ID = "debugkeybind";
1513

16-
public static final String VERSION = "9.0.0";
14+
public static final String VERSION = "1.2.0";
1715

1816
public static final String VERSION_STRING = MOD_NAME + " v" + VERSION;
1917

@@ -26,7 +24,7 @@ public static void init() {
2624

2725
CONFIG = BConfigHandler.registerConfig(KeybindConfig.class);
2826

29-
BCommandManager.register(F3Command.create());
27+
// BCommandManager.register(F3Command.create());
3028
}
3129

3230
}

common/src/main/java/dev/boxadactle/debugkeybind/command/CopySubcommand.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

common/src/main/java/dev/boxadactle/debugkeybind/command/DebugSubcommand.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

common/src/main/java/dev/boxadactle/debugkeybind/command/F3Command.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

common/src/main/java/dev/boxadactle/debugkeybind/command/ReloadSubcommand.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

common/src/main/java/dev/boxadactle/debugkeybind/command/ToggleSubcommand.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

common/src/main/java/dev/boxadactle/debugkeybind/gui/DebugKeybindsScreen.java

Lines changed: 110 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
package dev.boxadactle.debugkeybind.gui;
22

33
import dev.boxadactle.boxlib.gui.config.BOptionScreen;
4+
import dev.boxadactle.boxlib.gui.config.widget.button.BCustomButton;
45
import dev.boxadactle.boxlib.gui.config.widget.label.BCenteredLabel;
6+
import dev.boxadactle.boxlib.gui.config.widget.label.BLabel;
57
import dev.boxadactle.boxlib.util.ClientUtils;
68
import dev.boxadactle.debugkeybind.DebugKeybindMain;
79
import dev.boxadactle.debugkeybind.keybind.DebugKeybind;
810
import dev.boxadactle.debugkeybind.keybind.DebugKeybinds;
11+
import dev.boxadactle.debugkeybind.keybind.GlobalKeybind;
12+
import net.minecraft.client.KeyMapping;
13+
import net.minecraft.client.gui.components.AbstractWidget;
914
import net.minecraft.client.gui.components.Button;
1015
import net.minecraft.client.gui.screens.Screen;
16+
import net.minecraft.client.resources.language.I18n;
1117
import net.minecraft.network.chat.Component;
1218

19+
import java.util.List;
20+
import java.util.function.Function;
21+
1322
public class DebugKeybindsScreen extends BOptionScreen {
1423

1524
KeybindEntry selectedEntry;
@@ -19,8 +28,8 @@ public DebugKeybindsScreen(Screen parent) {
1928
}
2029

2130
@Override
22-
protected Component getName() {
23-
return Component.translatable("controls.keybinds.debug.title");
31+
protected String getName() {
32+
return I18n.get("controls.keybinds.debug.title");
2433
}
2534

2635
@Override
@@ -48,28 +57,28 @@ protected void initFooter(int startX, int startY) {
4857

4958
refreshEntries();
5059
});
51-
resetButton.setMessage(Component.translatable("controls.resetAll"));
60+
resetButton.setMessage(I18n.get("controls.resetAll"));
5261

5362
Button doneButton = createHalfDoneButton(startX, startY, (b) -> {
5463
ClientUtils.setScreen(parent);
5564

5665
DebugKeybindMain.CONFIG.save();
5766
});
58-
doneButton.setX(startX + getButtonWidth(ButtonType.SMALL) + getPadding());
67+
doneButton.x = (startX + getButtonWidth(ButtonType.SMALL) + getPadding());
5968

60-
addRenderableWidget(resetButton);
61-
addRenderableWidget(doneButton);
69+
addButton(resetButton);
70+
addButton(doneButton);
6271
}
6372

6473
@Override
6574
protected void initConfigButtons() {
66-
addConfigLine(new BCenteredLabel(Component.translatable("key.categories.debug")));
75+
addConfigLine(new BCenteredLabel(I18n.get("key.categories.debug")));
6776

6877
for (DebugKeybind keybind : DebugKeybinds.getGlobalKeybinds()) {
6978
addConfigLine(new KeybindEntry(keybind, this::setSelectedEntry, this::refreshEntries));
7079
}
7180

72-
addConfigLine(new BCenteredLabel(Component.translatable("key.categories.debug_actions")));
81+
addConfigLine(new BCenteredLabel(I18n.get("key.categories.debug_actions")));
7382

7483
for (DebugKeybind keybind : DebugKeybinds.getActionKeybinds()) {
7584
addConfigLine(new KeybindEntry(keybind, this::setSelectedEntry, this::refreshEntries));
@@ -104,4 +113,97 @@ public boolean mouseClicked(double d, double e, int i) {
104113

105114
return super.mouseClicked(d, e, i);
106115
}
116+
117+
@Override
118+
public void onClose() {
119+
super.onClose();
120+
121+
DebugKeybindMain.CONFIG.save();
122+
}
123+
124+
public class KeybindEntry extends ConfigEntry {
125+
public DebugKeybind keybind;
126+
127+
public BLabel label;
128+
public KeybindButton keybindButton;
129+
public ResetButton resetButton;
130+
131+
Runnable globalRefresh;
132+
133+
public KeybindEntry(DebugKeybind keybind, Function<KeybindEntry, Boolean> onSelect, Runnable refresh) {
134+
label = new BLabel(keybind.getTranslation());
135+
keybindButton = new KeybindButton(keybind, () -> onSelect.apply(this), DebugKeybindsScreen.this::renderTooltip);
136+
resetButton = new ResetButton(keybind, refresh);
137+
138+
this.keybind = keybind;
139+
140+
refresh();
141+
142+
this.globalRefresh = refresh;
143+
}
144+
145+
@Override
146+
public List<? extends AbstractWidget> getWidgets() {
147+
return List.of(label, keybindButton, resetButton);
148+
}
149+
150+
@Override
151+
public boolean isInvalid() {
152+
return false;
153+
}
154+
155+
public void updateKey(int code) {
156+
keybindButton.update(code);
157+
158+
refresh();
159+
globalRefresh.run();
160+
}
161+
162+
public void resetKey() {
163+
keybindButton.resetKey();
164+
165+
globalRefresh.run();
166+
}
167+
168+
public void refresh() {
169+
resetButton.refresh();
170+
171+
if (keybind.isUnbound()) {
172+
keybindButton.updateConflicts(List.of());
173+
return;
174+
}
175+
176+
List<String> collisions = keybind.checkConflicts(DebugKeybinds.toList());
177+
178+
if (keybind instanceof GlobalKeybind) {
179+
KeyMapping[] mappings = ClientUtils.getOptions().keyMappings.clone();
180+
181+
collisions.addAll(((GlobalKeybind) keybind).checkMinecraftConflicts(List.of(mappings)));
182+
}
183+
184+
keybindButton.updateConflicts(collisions);
185+
}
186+
187+
@Override
188+
public void render(int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
189+
int keybindWidth = 75;
190+
int resetWidth = 50;
191+
int padding = 2;
192+
193+
label.x = (x - 25);
194+
label.y = (y);
195+
label.setWidth(entryWidth - keybindWidth - resetWidth - padding);
196+
label.render(mouseX, mouseY, tickDelta);
197+
198+
keybindButton.x = (x + entryWidth - keybindWidth - resetWidth - padding);
199+
keybindButton.y =(y);
200+
keybindButton.setWidth(keybindWidth);
201+
keybindButton.render(mouseX, mouseY, tickDelta);
202+
203+
resetButton.x = (x + entryWidth - resetWidth);
204+
resetButton.y = (y);
205+
resetButton.setWidth(resetWidth);
206+
resetButton.render(mouseX, mouseY, tickDelta);
207+
}
208+
}
107209
}

0 commit comments

Comments
 (0)