Skip to content

Commit a76be72

Browse files
committed
Update to using Item#ABSOLUTE_MAX_STACK_SIZE instead of hardcoding the old max of 64
1 parent ae5c2b3 commit a76be72

File tree

15 files changed

+33
-26
lines changed

15 files changed

+33
-26
lines changed

src/datagen/generated/mekanism/.cache/c10fcd8abbb6a520fc3ac2cf14b627d36958dd55

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datagen/generated/mekanism/assets/mekanism/lang/en_ud.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datagen/generated/mekanism/assets/mekanism/lang/en_us.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datagen/main/java/mekanism/client/lang/MekanismLangProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ private void addMisc() {
13031303
add(MekanismLang.ITEM_FILTER_NO_ITEM, "No item");
13041304
add(MekanismLang.SORTER_FILTER_SIZE_MODE, "%1$s!");
13051305
add(MekanismLang.SORTER_FILTER_MAX_LESS_THAN_MIN, "Max < min");
1306-
add(MekanismLang.SORTER_FILTER_OVER_SIZED, "Max > 64");
1306+
add(MekanismLang.SORTER_FILTER_OVER_SIZED, "Max > %1$s");
13071307
add(MekanismLang.SORTER_FILTER_SIZE_MISSING, "Max/min");
13081308
add(MekanismLang.OREDICTIONIFICATOR_FILTER, "Oredictionificator Filter");
13091309
add(MekanismLang.OREDICTIONIFICATOR_FILTER_INVALID_NAMESPACE, "Invalid tag namespace");

src/main/java/mekanism/client/gui/element/window/filter/GuiFilter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import net.minecraft.client.gui.screens.Screen;
3131
import net.minecraft.network.chat.Component;
3232
import net.minecraft.world.item.BlockItem;
33+
import net.minecraft.world.item.Item;
3334
import net.minecraft.world.item.ItemStack;
3435
import org.jetbrains.annotations.NotNull;
3536
import org.jetbrains.annotations.Nullable;
@@ -174,14 +175,14 @@ protected static <FILTER extends SorterFilter<FILTER>> void validateAndSaveSorte
174175
} else {
175176
int min = Integer.parseInt(minField.getText());
176177
int max = Integer.parseInt(maxField.getText());
177-
if (max >= min && max <= 64) {
178+
if (max >= min && max <= Item.ABSOLUTE_MAX_STACK_SIZE) {
178179
guiFilter.filter.min = min;
179180
guiFilter.filter.max = max;
180181
guiFilter.saveFilter();
181182
} else if (min > max) {
182183
guiFilter.filterSaveFailed(MekanismLang.SORTER_FILTER_MAX_LESS_THAN_MIN);
183-
} else { //max > 64 || min > 64
184-
guiFilter.filterSaveFailed(MekanismLang.SORTER_FILTER_OVER_SIZED);
184+
} else { //max > Item.ABSOLUTE_MAX_STACK_SIZE || min > Item.ABSOLUTE_MAX_STACK_SIZE
185+
guiFilter.filterSaveFailed(MekanismLang.SORTER_FILTER_OVER_SIZED, Item.ABSOLUTE_MAX_STACK_SIZE);
185186
}
186187
}
187188
} else {

src/main/java/mekanism/client/gui/element/window/filter/transporter/GuiSorterFilterHelper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import net.minecraft.client.gui.GuiGraphics;
2525
import net.minecraft.client.gui.components.events.ContainerEventHandler;
2626
import net.minecraft.client.gui.screens.Screen;
27+
import net.minecraft.world.item.Item;
2728

2829
public interface GuiSorterFilterHelper extends GuiFilterHelper<TileEntityLogisticalSorter>, IFancyFontRenderer, ContainerEventHandler {
2930

@@ -52,13 +53,14 @@ default void addSorterDefaults(IGuiWrapper gui, int slotOffset, UnaryOperator<Gu
5253
filter.allowDefault = !filter.allowDefault;
5354
return true;
5455
})).setTooltip(MekanismLang.FILTER_ALLOW_DEFAULT);
56+
int maxStackSizeDigits = Integer.toString(Item.ABSOLUTE_MAX_STACK_SIZE).length();
5557
GuiTextField minField = new GuiTextField(gui, this, relativeX + 169, relativeY + 31, 20, 11);
56-
minField.setMaxLength(2);
58+
minField.setMaxLength(maxStackSizeDigits);
5759
minField.setInputValidator(InputValidator.DIGIT);
5860
minField.setText(Integer.toString(getFilter().min));
5961
childAdder.apply(minField);
6062
GuiTextField maxField = new GuiTextField(gui, this, relativeX + 169, relativeY + 43, 20, 11);
61-
maxField.setMaxLength(2);
63+
maxField.setMaxLength(maxStackSizeDigits);
6264
maxField.setInputValidator(InputValidator.DIGIT);
6365
maxField.setText(Integer.toString(getFilter().max));
6466
childAdder.apply(maxField);

src/main/java/mekanism/common/attachments/containers/item/ComponentBackedInventorySlot.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
import mekanism.api.annotations.NothingNullByDefault;
1010
import mekanism.api.inventory.IInventorySlot;
1111
import mekanism.common.attachments.containers.ComponentBackedContainer;
12-
import mekanism.common.inventory.slot.BasicInventorySlot;
1312
import mekanism.common.registries.MekanismDataComponents;
1413
import mekanism.common.util.NBTUtils;
1514
import net.minecraft.core.HolderLookup;
1615
import net.minecraft.core.HolderLookup.Provider;
1716
import net.minecraft.core.component.DataComponentType;
1817
import net.minecraft.nbt.CompoundTag;
1918
import net.minecraft.nbt.Tag;
19+
import net.minecraft.world.item.Item;
2020
import net.minecraft.world.item.ItemStack;
2121
import org.jetbrains.annotations.NotNull;
2222

@@ -31,7 +31,7 @@ public class ComponentBackedInventorySlot extends ComponentBackedContainer<ItemS
3131

3232
public ComponentBackedInventorySlot(ItemStack attachedTo, int slotIndex, BiPredicate<@NotNull ItemStack, @NotNull AutomationType> canExtract,
3333
BiPredicate<@NotNull ItemStack, @NotNull AutomationType> canInsert, Predicate<@NotNull ItemStack> validator) {
34-
this(attachedTo, slotIndex, canExtract, canInsert, validator, true, BasicInventorySlot.DEFAULT_LIMIT);
34+
this(attachedTo, slotIndex, canExtract, canInsert, validator, true, Item.ABSOLUTE_MAX_STACK_SIZE);
3535
}
3636

3737
public ComponentBackedInventorySlot(ItemStack attachedTo, int slotIndex, BiPredicate<@NotNull ItemStack, @NotNull AutomationType> canExtract,

src/main/java/mekanism/common/content/qio/QIOCraftingTransferHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ protected BaseSimulatedInventory(List<HotBarSlot> hotBarSlots, List<MainInventor
295295
}
296296
stackSizes[slot] = remaining;
297297
inventory[slot] = stack;
298-
//Note: For our slots the max stack size of the slot itself is always 64, but we look it up anyway just in case things change
298+
//Note: For our slots the max stack size of the slot itself is always Item.ABSOLUTE_MAX_STACK_SIZE, but we look it up anyway just in case things change
299299
if (stack.isEmpty()) {
300300
slotLimits[slot] = inventorySlot.getMaxStackSize(stack);
301301
} else {

src/main/java/mekanism/common/content/qio/QIOCraftingWindow.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ private void craftingFinished(@NotNull Level world) {
244244
*/
245245
private int calculateMaxCraftAmount(@NotNull ItemStack stack, @Nullable QIOFrequency frequency) {
246246
int outputSize = stack.getCount();
247-
int inputSize = 64;
247+
//Note: We start at the absolute max stack size, rather than at integer max value just to be a little more accurate
248+
int inputSize = Item.ABSOLUTE_MAX_STACK_SIZE;
248249
for (IInventorySlot inputSlot : inputSlots) {
249250
int count = inputSlot.getCount();
250251
if (count > 0 && count < inputSize) {

src/main/java/mekanism/common/content/qio/QIOServerCraftingTransferHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ protected int getRemaining(int slot, ItemStack currentStored) {
325325
availableItemSpace += slotData.getUsed();
326326
if (slotData.getAvailable() == 0) {
327327
//If we used all that is available, we need to also free up an item type
328-
//Note: Given we can't use as much as a full integer as we have nine slots that stack up to a max of 64
328+
//Note: Given we can't use as much as a full integer as we have nine slots that stack up to a max of Item.ABSOLUTE_MAX_STACK_SIZE
329329
// if we get down to zero then we know that we actually used it all, and it isn't just the case that we
330330
// think we are at zero because of clamping a long to an int
331331
availableItemTypes++;

0 commit comments

Comments
 (0)