Skip to content

Commit

Permalink
Fix buttons in the circuit table not behaving correctly with keyboard…
Browse files Browse the repository at this point in the history
… inputs, closes #5856
  • Loading branch information
BluSunrize committed May 1, 2024
1 parent aea4eb5 commit 8c72a30
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -8,6 +8,7 @@
- Change recipe for hempcrete to make it cheaper to mass produce (voidsong-dragonfly)
- Fix covered conveyors crashing the game (BluSunrize)
- Fix multiblocks being broken by flowing water (BluSunrize)
- Fix buttons in the circuit table not behaving correctly with keyboard inputs (BluSunrize)

##### Version 1.20.4-11.1.0-172
- First release for 1.20.4
Expand Down
Expand Up @@ -162,6 +162,7 @@ private void updateButtons()
{
int inputCount = operator.getArgumentCount();
int inputStart = 130-(inputCount*10-1);
this.inputButtons.forEach(this::removeWidget);
this.inputButtons.clear();
for(int i = 0; i < inputCount; i++)
this.inputButtons.add(this.addRenderableWidget(GuiButtonLogicCircuitRegister.create(
Expand Down
Expand Up @@ -95,9 +95,9 @@ public boolean charTyped(char codePoint, int modifiers)
if(Character.isDigit(codePoint))
{
int number = Character.digit(codePoint, 10);
if(number>=0 && number<8)
if(number >= 0&&number < 8)
{
this.state.setValue(number+16); // plus 16 colors
this.state.setValue(number+15); // plus 15 colors, the final increment is done by onPress
this.onPress.onPress(this);
return true;
}
Expand All @@ -108,7 +108,9 @@ else if(Character.isAlphabetic(codePoint))
if(!options.isEmpty())
{
int next = (options.indexOf(this.getStateAsInt())+1)%options.size();
this.state.setValue(options.get(next));
// subtract one because final increment is done by onPress
int stateIdx = Math.floorMod(options.get(next)-1, states.length);
this.state.setValue(stateIdx);
this.onPress.onPress(this);
return true;
}
Expand Down

0 comments on commit 8c72a30

Please sign in to comment.