fixed stack size modifier ui not updating correctly

closes #211
This commit is contained in:
Ell 2024-09-27 16:38:31 +02:00
parent 5b96a9d5a2
commit 861f219806

View file

@ -35,8 +35,8 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
} }
}); });
var data = this.menu.moduleStack.getOrDefault(StackSizeModuleItem.Data.TYPE, StackSizeModuleItem.Data.DEFAULT); Supplier<StackSizeModuleItem.Data> data = () -> this.menu.moduleStack.getOrDefault(StackSizeModuleItem.Data.TYPE, StackSizeModuleItem.Data.DEFAULT);
textField.setValue(String.valueOf(data.maxStackSize())); textField.setValue(String.valueOf(data.get().maxStackSize()));
textField.setMaxLength(4); textField.setMaxLength(4);
textField.setResponder(s -> { textField.setResponder(s -> {
if (s.isEmpty()) if (s.isEmpty())
@ -44,7 +44,7 @@ public class StackSizeModuleGui extends AbstractPipeGui<StackSizeModuleContainer
var amount = Integer.parseInt(s); var amount = Integer.parseInt(s);
PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_AMOUNT, List.of(amount)); PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_AMOUNT, List.of(amount));
}); });
Supplier<Component> buttonText = () -> Component.translatable("info." + PrettyPipes.ID + ".limit_to_max_" + (data.limitToMaxStackSize() ? "on" : "off")); Supplier<Component> buttonText = () -> Component.translatable("info." + PrettyPipes.ID + ".limit_to_max_" + (data.get().limitToMaxStackSize() ? "on" : "off"));
this.addRenderableWidget(Button.builder(buttonText.get(), b -> { this.addRenderableWidget(Button.builder(buttonText.get(), b -> {
PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_MODULE_BUTTON, List.of()); PacketButton.sendAndExecute(this.menu.tile.getBlockPos(), ButtonResult.STACK_SIZE_MODULE_BUTTON, List.of());
b.setMessage(buttonText.get()); b.setMessage(buttonText.get());