Amount specifying screen is now limited to valid values.

Cherry picked from 3402fc538ad1c00b384e0f180f6654995142f432
This commit is contained in:
Darkere
2022-01-22 17:48:06 +01:00
committed by raoulvdberge
parent 2ff06d379e
commit b64aab9c59
3 changed files with 14 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
by [@necauqua](https://github.com/necauqua) and [@Darkere](https://github.com/Darkere).
- Fixed autocrafting task getting stuck if two tasks fulfilled each others requirements.
- Fixed fluid autocrafting breaking when using 2 stacks of the same fluid in a pattern.
- Amount specifying screen is now limited to valid values.
## [v1.10.0-beta.4] - 2021-12-28

View File

@@ -64,6 +64,18 @@ public abstract class AmountSpecifyingScreen<T extends AbstractContainerMenu> ex
amountField.setTextColor(RenderSettings.INSTANCE.getSecondaryColor());
amountField.setCanLoseFocus(false);
amountField.changeFocus(true);
amountField.setResponder(text -> {
int amount = 0;
try {
amount = Integer.parseInt(amountField.getText());
} catch (NumberFormatException e) {
// NO OP
}
if (amount > getMaxAmount()) {
amountField.setText(String.valueOf(getMaxAmount()));
}
});
addRenderableWidget(amountField);

View File

@@ -205,7 +205,7 @@ public abstract class BaseScreen<T extends AbstractContainerMenu> extends Abstra
minecraft.player,
slot.index,
slot.getItem(),
slot.getMaxStackSize(),
Math.min(slot.getMaxStackSize(), slot.getItem().getMaxStackSize()),
((FilterSlot) slot).isAlternativesAllowed() ? (parent -> new AlternativesScreen(
parent,
minecraft.player,