Skip to content

Commit c3a6965

Browse files
committed
Remove AE2's hotbar handling from our GUIs
Fixes #72
1 parent 023be50 commit c3a6965

8 files changed

Lines changed: 69 additions & 75 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The format is based on Keep a Changelog and this project adheres to Semantic Ver
1414
- Fix standalone Essentia Interfaces hiding filters past the first page.
1515
- Fix some jank interactions with the Configurable Cell's component slots, resulting in voiding components or being able to insert invalid components, in some cases. All cases should be fixed, now.
1616
- Fix Configurable Cell's warnings/errors using the old translation keys.
17+
- Remove AE2's hotbar handling (1-9 under F keys) from GUIs, where they may conflict with other numeric fields or keybinds.
1718

1819

1920
## [0.6.2-alpha2] - 2026-05-26

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ enable_junit_testing = false
1515
show_testing_output = false
1616

1717
# Mod Information
18-
mod_version = 0.6.2-alpha2
18+
mod_version = 0.6.2-alpha3
1919
root_package = com.cells
2020
mod_id = cells
2121
mod_name = C.E.L.L.S

src/main/java/com/cells/blocks/compactingpatternexposer/GuiCompactingPatternExposer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ protected void keyTyped(char typedChar, int keyCode) throws IOException {
133133
return;
134134
}
135135

136-
if (this.checkHotbarKeys(keyCode)) return;
137-
138136
if (KeyBindings.QUICK_ADD_TO_FILTER.isActiveAndMatches(keyCode)) {
139137
Slot hoveredSlot = this.getSlotUnderMouse();
140138
ItemStack stack = QuickAddHelper.getItemUnderCursor(hoveredSlot);

src/main/java/com/cells/blocks/interfacebase/GuiMaxSlotSize.java

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -268,78 +268,76 @@ private void addQty(final int delta) {
268268

269269
@Override
270270
protected void keyTyped(final char character, final int key) throws IOException {
271-
if (!this.checkHotbarKeys(key)) {
272-
// Commas are virtual (auto-formatted), so we need to skip over them when
273-
// pressing backspace or delete, otherwise the comma just gets re-added and
274-
// the user's keypress appears to do nothing.
275-
this.commaSkipped = false;
276-
277-
if (key == Keyboard.KEY_BACK) {
278-
String text = this.sizeField.getText();
279-
int cursor = this.sizeField.getCursorPosition();
280-
281-
if (cursor > 0 && text.charAt(cursor - 1) == ',') {
282-
this.sizeField.setCursorPosition(cursor - 1);
283-
this.commaSkipped = true;
284-
}
285-
} else if (key == Keyboard.KEY_DELETE) {
286-
String text = this.sizeField.getText();
287-
int cursor = this.sizeField.getCursorPosition();
271+
// Commas are virtual (auto-formatted), so we need to skip over them when
272+
// pressing backspace or delete, otherwise the comma just gets re-added and
273+
// the user's keypress appears to do nothing.
274+
this.commaSkipped = false;
275+
276+
if (key == Keyboard.KEY_BACK) {
277+
String text = this.sizeField.getText();
278+
int cursor = this.sizeField.getCursorPosition();
279+
280+
if (cursor > 0 && text.charAt(cursor - 1) == ',') {
281+
this.sizeField.setCursorPosition(cursor - 1);
282+
this.commaSkipped = true;
283+
}
284+
} else if (key == Keyboard.KEY_DELETE) {
285+
String text = this.sizeField.getText();
286+
int cursor = this.sizeField.getCursorPosition();
288287

289-
if (cursor < text.length() && text.charAt(cursor) == ',') {
290-
this.sizeField.setCursorPosition(cursor + 1);
291-
this.commaSkipped = true;
292-
}
288+
if (cursor < text.length() && text.charAt(cursor) == ',') {
289+
this.sizeField.setCursorPosition(cursor + 1);
290+
this.commaSkipped = true;
293291
}
292+
}
294293

295-
if ((key == Keyboard.KEY_DELETE || key == Keyboard.KEY_RIGHT
296-
|| key == Keyboard.KEY_LEFT || key == Keyboard.KEY_BACK
297-
|| Character.isDigit(character)) && this.sizeField.textboxKeyTyped(character, key)) {
294+
if ((key == Keyboard.KEY_DELETE || key == Keyboard.KEY_RIGHT
295+
|| key == Keyboard.KEY_LEFT || key == Keyboard.KEY_BACK
296+
|| Character.isDigit(character)) && this.sizeField.textboxKeyTyped(character, key)) {
298297

299-
String out = this.sizeField.getText();
298+
String out = this.sizeField.getText();
300299

301-
// Remove commas from thousand separators
302-
out = out.replaceAll(",", "");
300+
// Remove commas from thousand separators
301+
out = out.replaceAll(",", "");
303302

304-
// Remove leading zeros
305-
while (out.startsWith("0") && out.length() > 1) {
306-
out = out.substring(1);
307-
}
303+
// Remove leading zeros
304+
while (out.startsWith("0") && out.length() > 1) {
305+
out = out.substring(1);
306+
}
308307

309-
if (out.isEmpty()) {
310-
if (isOverrideMode()) {
311-
// In per-slot mode, empty field clears the override
312-
this.currentMaxSlotSize = 0;
313-
CellsNetworkHandler.INSTANCE.sendToServer(new PacketSetMaxSlotSize(-1));
314-
}
315-
// In global mode, empty field is just unsaved (no packet sent)
316-
} else {
317-
try {
318-
// Parse as long to handle large values
319-
this.onQtyChanged(Long.parseLong(out));
320-
} catch (final NumberFormatException e) {
321-
// Parsing failed should mean we exceeded Long.MAX_VALUE, so clamp to max
322-
this.onQtyChanged(Long.MAX_VALUE);
323-
}
308+
if (out.isEmpty()) {
309+
if (isOverrideMode()) {
310+
// In per-slot mode, empty field clears the override
311+
this.currentMaxSlotSize = 0;
312+
CellsNetworkHandler.INSTANCE.sendToServer(new PacketSetMaxSlotSize(-1));
324313
}
314+
// In global mode, empty field is just unsaved (no packet sent)
315+
} else {
316+
try {
317+
// Parse as long to handle large values
318+
this.onQtyChanged(Long.parseLong(out));
319+
} catch (final NumberFormatException e) {
320+
// Parsing failed should mean we exceeded Long.MAX_VALUE, so clamp to max
321+
this.onQtyChanged(Long.MAX_VALUE);
322+
}
323+
}
325324

326-
// After all processing (including potential reformat), if we
327-
// pre-skipped a comma for backspace/delete, nudge the cursor past
328-
// the comma so it lands on the correct side. This runs even when
329-
// onQtyChanged didn't reformat (text unchanged).
330-
if (this.commaSkipped) {
331-
String finalText = this.sizeField.getText();
332-
int cur = this.sizeField.getCursorPosition();
333-
334-
if (cur < finalText.length() && finalText.charAt(cur) == ',') {
335-
this.sizeField.setCursorPosition(cur + 1);
336-
}
325+
// After all processing (including potential reformat), if we
326+
// pre-skipped a comma for backspace/delete, nudge the cursor past
327+
// the comma so it lands on the correct side. This runs even when
328+
// onQtyChanged didn't reformat (text unchanged).
329+
if (this.commaSkipped) {
330+
String finalText = this.sizeField.getText();
331+
int cur = this.sizeField.getCursorPosition();
337332

338-
this.commaSkipped = false;
333+
if (cur < finalText.length() && finalText.charAt(cur) == ',') {
334+
this.sizeField.setCursorPosition(cur + 1);
339335
}
340-
} else {
341-
super.keyTyped(character, key);
342-
}
336+
337+
this.commaSkipped = false;
338+
}
339+
} else {
340+
super.keyTyped(character, key);
343341
}
344342
}
345343
}

src/main/java/com/cells/cells/configurable/GuiConfigurableCell.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
122122

123123
@Override
124124
protected void keyTyped(char character, int key) throws IOException {
125-
if (this.checkHotbarKeys(key)) return;
126-
127125
boolean isValidKey = key == Keyboard.KEY_DELETE || key == Keyboard.KEY_RIGHT
128126
|| key == Keyboard.KEY_LEFT || key == Keyboard.KEY_BACK
129127
|| Character.isDigit(character);
@@ -150,6 +148,11 @@ protected void keyTyped(char character, int key) throws IOException {
150148
}
151149
}
152150

151+
// We could handle hotbar keys, but it is likely to just be triggered by accident,
152+
// and yank the cell out of the player's hand while they're trying to type a number,
153+
// because they tried to type the number the cell was on.
154+
// if (this.checkHotbarKeys(key)) return;
155+
153156
super.keyTyped(character, key);
154157
}
155158

src/main/java/com/cells/cells/creative/AbstractCreativeCellGui.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,6 @@ public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
181181

182182
@Override
183183
protected void keyTyped(char typedChar, int keyCode) throws IOException {
184-
if (this.checkHotbarKeys(keyCode)) return;
185-
186184
// Handle quick-add keybind
187185
if (KeyBindings.QUICK_ADD_TO_FILTER.isActiveAndMatches(keyCode)) {
188186
Slot hoveredSlot = this.getSlotUnderMouse();

src/main/java/com/cells/gui/subnetproxy/GuiSubnetProxy.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,6 @@ public List<Target<?>> getPhantomTargets(Object ingredient) {
407407

408408
@Override
409409
protected void keyTyped(char typedChar, int keyCode) throws IOException {
410-
if (this.checkHotbarKeys(keyCode)) return;
411-
412410
// Handle quick-add keybind
413411
if (KeyBindings.QUICK_ADD_TO_FILTER.isActiveAndMatches(keyCode)) {
414412
Slot hoveredSlot = this.getSlotUnderMouse();

src/main/java/com/cells/items/pullpush/GuiPullPushCard.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,6 @@ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOEx
369369

370370
@Override
371371
protected void keyTyped(final char character, final int key) throws IOException {
372-
if (this.checkHotbarKeys(key)) return;
373-
374372
// Determine which text field is focused (if any)
375373
GuiTextField activeField = null;
376374
if (this.quantityField.isFocused()) {
@@ -390,12 +388,12 @@ protected void keyTyped(final char character, final int key) throws IOException
390388
if (this.quantityField.isFocused()) {
391389
this.quantityField.setFocused(false);
392390
this.keepsField.setFocused(true);
393-
} else {
391+
return;
392+
} else if (this.keepsField.isFocused()) {
394393
this.keepsField.setFocused(false);
395394
this.quantityField.setFocused(true);
395+
return;
396396
}
397-
398-
return;
399397
}
400398

401399
// Commas are virtual (auto-formatted), so we need to skip over them when

0 commit comments

Comments
 (0)