From 3e065bd0c8a00476ad1a6fae713c99688d9d1715 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Thu, 14 Mar 2024 20:19:26 +0100 Subject: [PATCH] Switch to using the ConfigInventory builder --- .../api/storage/cells/ICellWorkbenchItem.java | 2 +- .../java/appeng/helpers/InterfaceLogic.java | 7 +- .../modules/emi/AppEngEmiPlugin.java | 14 +-- .../modules/emi/EmiFacadeGenerator.java | 34 +++--- .../appeng/items/contents/CellConfig.java | 9 +- .../parts/automation/FormationPlanePart.java | 6 +- .../appeng/parts/automation/IOBusPart.java | 3 +- .../automation/StorageLevelEmitterPart.java | 3 +- .../parts/encoding/PatternEncodingLogic.java | 10 +- .../parts/storagebus/StorageBusPart.java | 3 +- .../java/appeng/util/ConfigInventory.java | 114 ++++++++++++++---- .../patternprovider/GenericStackInvTest.java | 3 +- .../java/appeng/util/ConfigInventoryTest.java | 8 +- .../appeng/util/ConfigMenuInventoryTest.java | 7 +- 14 files changed, 144 insertions(+), 79 deletions(-) diff --git a/src/main/java/appeng/api/storage/cells/ICellWorkbenchItem.java b/src/main/java/appeng/api/storage/cells/ICellWorkbenchItem.java index 19b2a38da59..d04f846071f 100644 --- a/src/main/java/appeng/api/storage/cells/ICellWorkbenchItem.java +++ b/src/main/java/appeng/api/storage/cells/ICellWorkbenchItem.java @@ -49,7 +49,7 @@ default boolean isEditable(ItemStack is) { * onInventoryChange will be called when saving is needed. */ default ConfigInventory getConfigInventory(ItemStack is) { - return ConfigInventory.EMPTY_TYPES; + return ConfigInventory.emptyTypes(); } /** diff --git a/src/main/java/appeng/helpers/InterfaceLogic.java b/src/main/java/appeng/helpers/InterfaceLogic.java index 51a71d806a2..cd62938e871 100644 --- a/src/main/java/appeng/helpers/InterfaceLogic.java +++ b/src/main/java/appeng/helpers/InterfaceLogic.java @@ -47,7 +47,6 @@ import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickingRequest; import appeng.api.stacks.AEKey; -import appeng.api.stacks.AEKeyTypes; import appeng.api.stacks.GenericStack; import appeng.api.storage.MEStorage; import appeng.api.storage.StorageHelper; @@ -103,9 +102,9 @@ public InterfaceLogic(IManagedGridNode gridNode, InterfaceLogicHost host, Item i public InterfaceLogic(IManagedGridNode gridNode, InterfaceLogicHost host, Item is, int slots) { this.host = host; - this.config = ConfigInventory.configStacks(AEKeyTypes.getAll(), slots, this::onConfigRowChanged, false); - this.storage = ConfigInventory.storage(AEKeyTypes.getAll(), this::isAllowedInStorageSlot, slots, - this::onStorageChanged); + this.config = ConfigInventory.configStacks(slots).changeListener(this::onConfigRowChanged).build(); + this.storage = ConfigInventory.storage(slots).slotFilter(this::isAllowedInStorageSlot) + .changeListener(this::onStorageChanged).build(); this.mainNode = gridNode .setFlags(GridFlags.REQUIRE_CHANNEL) .addService(IGridTickable.class, new Ticker()); diff --git a/src/main/java/appeng/integration/modules/emi/AppEngEmiPlugin.java b/src/main/java/appeng/integration/modules/emi/AppEngEmiPlugin.java index d32d46af799..c6073e46d73 100644 --- a/src/main/java/appeng/integration/modules/emi/AppEngEmiPlugin.java +++ b/src/main/java/appeng/integration/modules/emi/AppEngEmiPlugin.java @@ -2,7 +2,6 @@ import java.util.Arrays; import java.util.List; -import java.util.Optional; import java.util.function.Consumer; import java.util.function.Function; @@ -29,6 +28,7 @@ import appeng.api.integrations.emi.EmiStackConverters; import appeng.core.AEConfig; import appeng.core.AppEng; +import appeng.core.FacadeCreativeTab; import appeng.core.definitions.AEBlocks; import appeng.core.definitions.AEItems; import appeng.core.definitions.AEParts; @@ -106,7 +106,9 @@ public void register(EmiRegistry registry) { adaptRecipeType(registry, TransformRecipe.TYPE, EmiTransformRecipe::new); // Facades - registry.addDeferredRecipes(this::registerFacades); + if (AEConfig.instance().isEnableFacadeRecipesInJEI()) { + registry.addDeferredRecipes(this::registerFacades); + } // Remove items if (!AEConfig.instance().isEnableFacadesInJEI()) { @@ -189,10 +191,8 @@ private void registerP2PAttunements(Consumer recipeConsumer) { private void registerFacades(Consumer recipeConsumer) { var generator = new EmiFacadeGenerator(); - EmiApi.getIndexStacks().stream() - .map(generator::getRecipeFor) - .filter(Optional::isPresent) - .map(Optional::get) - .forEach(recipeConsumer); + for (var facade : FacadeCreativeTab.getDisplayItems()) { + generator.getRecipeFor(facade).ifPresent(recipeConsumer); + } } } diff --git a/src/main/java/appeng/integration/modules/emi/EmiFacadeGenerator.java b/src/main/java/appeng/integration/modules/emi/EmiFacadeGenerator.java index 8d576e207df..7f7dfa7c26e 100644 --- a/src/main/java/appeng/integration/modules/emi/EmiFacadeGenerator.java +++ b/src/main/java/appeng/integration/modules/emi/EmiFacadeGenerator.java @@ -17,44 +17,44 @@ * This plugin will dynamically add facade recipes for any item that can be turned into a facade. */ class EmiFacadeGenerator { - private final ItemStack cableAnchor; + private final EmiStack cableAnchor; EmiFacadeGenerator() { - this.cableAnchor = AEParts.CABLE_ANCHOR.stack(); + this.cableAnchor = EmiStack.of(AEParts.CABLE_ANCHOR.stack()); } - public Optional getRecipeFor(EmiStack emiStack) { - var itemStack = emiStack.getItemStack(); - if (itemStack.isEmpty()) { + public Optional getRecipeFor(ItemStack potentialFacade) { + if (potentialFacade.isEmpty()) { return Optional.empty(); // We only have items } - // Looking up how a certain facade is crafted - if (itemStack.getItem() instanceof FacadeItem facadeItem) { - ItemStack textureItem = facadeItem.getTextureItem(itemStack); - return Optional.of(make(textureItem, this.cableAnchor, itemStack.copy())); + if (potentialFacade.getItem() instanceof FacadeItem facadeItem) { + ItemStack textureItem = facadeItem.getTextureItem(potentialFacade); + return Optional.of(make(textureItem, potentialFacade.copy())); } return Optional.empty(); } - private EmiRecipe make(ItemStack textureItem, ItemStack cableAnchor, ItemStack result) { + private EmiRecipe make(ItemStack textureItem, ItemStack result) { + var textureStack = EmiStack.of(textureItem); + var resultStack = EmiStack.of(result, 4); + var input = List.of( EmiStack.EMPTY, - EmiStack.of(cableAnchor), + cableAnchor, EmiStack.EMPTY, - EmiStack.of(cableAnchor), - EmiStack.of(textureItem), - EmiStack.of(cableAnchor), + cableAnchor, + textureStack, + cableAnchor, EmiStack.EMPTY, - EmiStack.of(cableAnchor), + cableAnchor, EmiStack.EMPTY); return new EmiCraftingRecipe( input, - EmiStack.of(result, 4), + resultStack, null, false); } - } diff --git a/src/main/java/appeng/items/contents/CellConfig.java b/src/main/java/appeng/items/contents/CellConfig.java index af80051a31f..4607ca1af27 100644 --- a/src/main/java/appeng/items/contents/CellConfig.java +++ b/src/main/java/appeng/items/contents/CellConfig.java @@ -25,7 +25,6 @@ import net.minecraft.world.item.ItemStack; import appeng.api.stacks.AEKeyType; -import appeng.api.stacks.AEKeyTypes; import appeng.util.ConfigInventory; public final class CellConfig { @@ -36,21 +35,23 @@ public static ConfigInventory create(Set supportedTypes, ItemStack is Preconditions.checkArgument(size >= 1 && size <= 63, "Config inventory must have between 1 and 63 slots inclusive."); var holder = new Holder(is); - holder.inv = ConfigInventory.configTypes(supportedTypes, size, holder::save); + holder.inv = ConfigInventory.configTypes(size).supportedTypes(supportedTypes).changeListener(holder::save) + .build(); holder.load(); return holder.inv; } public static ConfigInventory create(Set supportedTypes, ItemStack is) { var holder = new Holder(is); - holder.inv = ConfigInventory.configTypes(supportedTypes, 63, holder::save); + holder.inv = ConfigInventory.configTypes(63).supportedTypes(supportedTypes).changeListener(holder::save) + .build(); holder.load(); return holder.inv; } public static ConfigInventory create(ItemStack is) { var holder = new Holder(is); - holder.inv = ConfigInventory.configTypes(AEKeyTypes.getAll(), 63, holder::save); + holder.inv = ConfigInventory.configTypes(63).changeListener(holder::save).build(); holder.load(); return holder.inv; } diff --git a/src/main/java/appeng/parts/automation/FormationPlanePart.java b/src/main/java/appeng/parts/automation/FormationPlanePart.java index 765e5ca4537..90f30a4a7c1 100644 --- a/src/main/java/appeng/parts/automation/FormationPlanePart.java +++ b/src/main/java/appeng/parts/automation/FormationPlanePart.java @@ -82,8 +82,10 @@ public class FormationPlanePart extends UpgradeablePart implements IStorageProvi public FormationPlanePart(IPartItem partItem) { super(partItem); getMainNode().addService(IStorageProvider.class, this); - this.config = ConfigInventory.configTypes(StackWorldBehaviors.withPlacementStrategy(), - 63, this::updateFilter); + this.config = ConfigInventory.configTypes(63) + .supportedTypes(StackWorldBehaviors.withPlacementStrategy()) + .changeListener(this::updateFilter) + .build(); this.getConfigManager().registerSetting(Settings.PLACE_BLOCK, YesNo.YES); this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL); diff --git a/src/main/java/appeng/parts/automation/IOBusPart.java b/src/main/java/appeng/parts/automation/IOBusPart.java index 83caeb4bb06..2925fb56e86 100644 --- a/src/main/java/appeng/parts/automation/IOBusPart.java +++ b/src/main/java/appeng/parts/automation/IOBusPart.java @@ -92,7 +92,8 @@ public IOBusPart(TickRates tickRates, Set supportedKeyTypes, IPartIte super(partItem); this.tickRates = tickRates; this.source = new MachineSource(this); - this.config = ConfigInventory.configTypes(supportedKeyTypes, 63, this::updateState); + this.config = ConfigInventory.configTypes(63).supportedTypes(supportedKeyTypes) + .changeListener(this::updateState).build(); getMainNode().addService(IGridTickable.class, this); this.getConfigManager().registerSetting(Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE); diff --git a/src/main/java/appeng/parts/automation/StorageLevelEmitterPart.java b/src/main/java/appeng/parts/automation/StorageLevelEmitterPart.java index 9f8f4282c2e..c6a81348ebf 100644 --- a/src/main/java/appeng/parts/automation/StorageLevelEmitterPart.java +++ b/src/main/java/appeng/parts/automation/StorageLevelEmitterPart.java @@ -80,7 +80,8 @@ public class StorageLevelEmitterPart extends AbstractLevelEmitterPart public static final PartModel MODEL_ON_ON = new PartModel(MODEL_BASE_ON, MODEL_STATUS_ON); public static final PartModel MODEL_ON_HAS_CHANNEL = new PartModel(MODEL_BASE_ON, MODEL_STATUS_HAS_CHANNEL); - private final ConfigInventory config = ConfigInventory.configTypes(1, this::configureWatchers); + private final ConfigInventory config = ConfigInventory.configTypes(1).changeListener(this::configureWatchers) + .build(); private IStackWatcher storageWatcher; private IStackWatcher craftingWatcher; private long lastUpdateTick = -1; diff --git a/src/main/java/appeng/parts/encoding/PatternEncodingLogic.java b/src/main/java/appeng/parts/encoding/PatternEncodingLogic.java index 61283b53412..3233fad5dca 100644 --- a/src/main/java/appeng/parts/encoding/PatternEncodingLogic.java +++ b/src/main/java/appeng/parts/encoding/PatternEncodingLogic.java @@ -28,7 +28,6 @@ import appeng.api.crafting.PatternDetailsHelper; import appeng.api.inventories.InternalInventory; import appeng.api.stacks.AEItemKey; -import appeng.api.stacks.AEKeyTypes; import appeng.api.stacks.GenericStack; import appeng.core.definitions.AEItems; import appeng.crafting.pattern.AECraftingPattern; @@ -49,10 +48,11 @@ public class PatternEncodingLogic implements InternalInventoryHost { AEProcessingPattern.MAX_INPUT_SLOTS); private static final int MAX_OUTPUT_SLOTS = AEProcessingPattern.MAX_OUTPUT_SLOTS; - private final ConfigInventory encodedInputInv = ConfigInventory.configStacks(AEKeyTypes.getAll(), MAX_INPUT_SLOTS, - this::onEncodedInputChanged, true); - private final ConfigInventory encodedOutputInv = ConfigInventory.configStacks(AEKeyTypes.getAll(), MAX_OUTPUT_SLOTS, - this::onEncodedOutputChanged, true); + private final ConfigInventory encodedInputInv = ConfigInventory.configStacks(MAX_INPUT_SLOTS) + .changeListener(this::onEncodedInputChanged).allowOverstacking(true).build(); + private final ConfigInventory encodedOutputInv = ConfigInventory.configStacks(MAX_OUTPUT_SLOTS) + .changeListener(this::onEncodedOutputChanged).allowOverstacking(true).build(); + private final AppEngInternalInventory blankPatternInv = new AppEngInternalInventory(this, 1); private final AppEngInternalInventory encodedPatternInv = new AppEngInternalInventory(this, 1); diff --git a/src/main/java/appeng/parts/storagebus/StorageBusPart.java b/src/main/java/appeng/parts/storagebus/StorageBusPart.java index afe7315a750..838d80c58ef 100644 --- a/src/main/java/appeng/parts/storagebus/StorageBusPart.java +++ b/src/main/java/appeng/parts/storagebus/StorageBusPart.java @@ -107,7 +107,8 @@ public class StorageBusPart extends UpgradeablePart new ResourceLocation(AppEng.MOD_ID, "part/storage_bus_has_channel")); protected final IActionSource source; - private final ConfigInventory config = ConfigInventory.configTypes(63, this::onConfigurationChanged); + private final ConfigInventory config = ConfigInventory.configTypes(63).changeListener(this::onConfigurationChanged) + .build(); /** * This is the virtual inventory this storage bus exposes to the network it belongs to. To avoid continuous * cell-change notifications, we instead use a handler that will exist as long as this storage bus exists, while diff --git a/src/main/java/appeng/util/ConfigInventory.java b/src/main/java/appeng/util/ConfigInventory.java index 50fec16d6ea..6ee67d7997e 100644 --- a/src/main/java/appeng/util/ConfigInventory.java +++ b/src/main/java/appeng/util/ConfigInventory.java @@ -1,5 +1,6 @@ package appeng.util; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; @@ -39,14 +40,24 @@ public class ConfigInventory extends GenericStackInv { /** * An empty config-type inventory. + * + * @deprecated use #empty() */ - public static final ConfigInventory EMPTY_TYPES = ConfigInventory.configTypes(AEKeyTypes.getAll(), 0, null); + @Deprecated(since = "1.20.4") + public static final ConfigInventory EMPTY_TYPES = ConfigInventory.configTypes(0).build(); - protected ConfigInventory(Set supportedKeyTypes, @Nullable AEKeySlotFilter slotFilter, + /** + * @return A read-only, empty inventory that is in types mode. + */ + public static ConfigInventory emptyTypes() { + return EMPTY_TYPES; + } + + protected ConfigInventory(Set supportedTypes, @Nullable AEKeySlotFilter slotFilter, Mode mode, int size, @Nullable Runnable listener, boolean allowOverstacking) { - super(supportedKeyTypes, listener, mode, size); + super(supportedTypes, listener, mode, size); this.allowOverstacking = allowOverstacking; setFilter(slotFilter); } @@ -54,7 +65,7 @@ protected ConfigInventory(Set supportedKeyTypes, @Nullable AEKeySlotF public final static class Builder { private final Mode mode; private final int size; - private Set supportedKeyTypes = AEKeyTypes.getAll(); + private Set supportedTypes = AEKeyTypes.getAll(); @Nullable private AEKeySlotFilter slotFilter; @Nullable @@ -66,18 +77,26 @@ private Builder(Mode mode, int size) { this.size = size; } - public Builder supportedKeyType(AEKeyType keyType) { - this.supportedKeyTypes = Set.of(keyType); + public Builder supportedType(AEKeyType type) { + this.supportedTypes = Set.of(type); + return this; + } + + public Builder supportedTypes(AEKeyType type, AEKeyType... moreTypes) { + if (moreTypes.length == 0) { + return supportedType(type); + } + this.supportedTypes = new HashSet<>(1 + moreTypes.length); + this.supportedTypes.add(type); + Collections.addAll(this.supportedTypes, moreTypes); return this; } - public Builder supportedKeyTypes(AEKeyType keyType, AEKeyType... moreKeyTypes) { - if (moreKeyTypes.length == 0) { - return supportedKeyType(keyType); + public Builder supportedTypes(Collection types) { + if (types.isEmpty()) { + throw new IllegalArgumentException("Configuration inventories must support at least one key type"); } - this.supportedKeyTypes = new HashSet<>(1 + moreKeyTypes.length); - this.supportedKeyTypes.add(keyType); - Collections.addAll(this.supportedKeyTypes, moreKeyTypes); + this.supportedTypes = Set.copyOf(types); return this; } @@ -103,7 +122,7 @@ public Builder changeListener(Runnable changeListener) { } /** - * Allow slots to exceed the natural stack size limits of items. + * Allow slots to exceed the natural stack size limits of items. This is false by default. */ public Builder allowOverstacking(boolean enable) { this.allowOverstacking = enable; @@ -112,7 +131,7 @@ public Builder allowOverstacking(boolean enable) { public ConfigInventory build() { return new ConfigInventory( - supportedKeyTypes, + supportedTypes, slotFilter, mode, size, @@ -145,51 +164,96 @@ public static Builder storage(int size) { /** * When in types mode, the config inventory will ignore all amounts and always return amount 1 for stacks in the * inventory. + * + * @deprecated Use the builder {@link #configTypes(int)) */ + @Deprecated(since = "1.20.4") public static ConfigInventory configTypes(int size, @Nullable Runnable changeListener) { - return new ConfigInventory(AEKeyTypes.getAll(), null, Mode.CONFIG_TYPES, size, changeListener, false); + var builder = configTypes(size); + if (changeListener != null) { + builder.changeListener(changeListener); + } + return builder.build(); } /** * When in types mode, the config inventory will ignore all amounts and always return amount 1 for stacks in the * inventory. + * + * @deprecated Use the builder {@link #configTypes(int)) */ - public static ConfigInventory configTypes(Set supportedKeyTypes, int size, + @Deprecated(since = "1.20.4") + public static ConfigInventory configTypes(Set supportedTypes, int size, @Nullable Runnable changeListener) { - return new ConfigInventory(supportedKeyTypes, null, Mode.CONFIG_TYPES, size, changeListener, false); + var builder = configTypes(size).supportedTypes(supportedTypes); + if (changeListener != null) { + builder.changeListener(changeListener); + } + return builder.build(); } /** * When in stack mode, the config inventory will respect amounts and drop stacks with amounts of 0 or less. + * + * @deprecated Use the builder {@link #configTypes(int)) */ - public static ConfigInventory configStacks(Set supportedKeyTypes, int size, + @Deprecated(since = "1.20.4") + public static ConfigInventory configStacks(Set supportedTypes, int size, @Nullable Runnable changeListener, boolean allowOverstacking) { - return new ConfigInventory(supportedKeyTypes, null, Mode.CONFIG_STACKS, size, changeListener, - allowOverstacking); + var builder = configStacks(size).supportedTypes(supportedTypes); + if (changeListener != null) { + builder.changeListener(changeListener); + } + builder.allowOverstacking(allowOverstacking); + return builder.build(); } /** * When in stack mode, the config inventory will respect amounts and drop stacks with amounts of 0 or less. + * + * @deprecated Use the builder {@link #configTypes(int)) */ + @Deprecated(since = "1.20.4") public static ConfigInventory storage(int size, @Nullable Runnable changeListener) { - return new ConfigInventory(AEKeyTypes.getAll(), null, Mode.STORAGE, size, changeListener, false); + var builder = storage(size); + if (changeListener != null) { + builder.changeListener(changeListener); + } + return builder.build(); } /** * When in stack mode, the config inventory will respect amounts and drop stacks with amounts of 0 or less. + * + * @deprecated Use the builder {@link #configTypes(int)) */ - public static ConfigInventory storage(Set supportedKeyTypes, int size, + @Deprecated(since = "1.20.4") + public static ConfigInventory storage(Set supportedTypes, int size, @Nullable Runnable changeListener) { - return new ConfigInventory(supportedKeyTypes, null, Mode.STORAGE, size, changeListener, false); + var builder = storage(size).supportedTypes(supportedTypes); + if (changeListener != null) { + builder.changeListener(changeListener); + } + return builder.build(); } /** * When in stack mode, the config inventory will respect amounts and drop stacks with amounts of 0 or less. + * + * @deprecated Use the builder {@link #configTypes(int)) */ - public static ConfigInventory storage(Set supportedKeyTypes, @Nullable AEKeySlotFilter slotFilter, + @Deprecated(since = "1.20.4") + public static ConfigInventory storage(Set supportedTypes, @Nullable AEKeySlotFilter slotFilter, int size, @Nullable Runnable changeListener) { - return new ConfigInventory(supportedKeyTypes, slotFilter, Mode.STORAGE, size, changeListener, false); + var builder = storage(size).supportedTypes(supportedTypes); + if (slotFilter != null) { + builder.slotFilter(slotFilter); + } + if (changeListener != null) { + builder.changeListener(changeListener); + } + return builder.build(); } @Nullable diff --git a/src/test/java/appeng/helpers/patternprovider/GenericStackInvTest.java b/src/test/java/appeng/helpers/patternprovider/GenericStackInvTest.java index 60cf49f009c..405572f3250 100644 --- a/src/test/java/appeng/helpers/patternprovider/GenericStackInvTest.java +++ b/src/test/java/appeng/helpers/patternprovider/GenericStackInvTest.java @@ -7,7 +7,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import org.junit.jupiter.api.Nested; @@ -52,7 +51,7 @@ void testIsEmptyOnNonEmptyInventory() { */ @Test void testSaveLargeAndLoadIntoSmallerInventory() { - var large = ConfigInventory.configStacks(Set.of(AEKeyType.items()), 2, null, false); + var large = ConfigInventory.configStacks(2).supportedType(AEKeyType.items()).build(); large.setStack(0, ONE_STICK); large.setStack(1, ONE_STICK); diff --git a/src/test/java/appeng/util/ConfigInventoryTest.java b/src/test/java/appeng/util/ConfigInventoryTest.java index 35faebb5bd6..a2e8b556476 100644 --- a/src/test/java/appeng/util/ConfigInventoryTest.java +++ b/src/test/java/appeng/util/ConfigInventoryTest.java @@ -3,8 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import java.util.Set; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -30,7 +28,7 @@ public class ConfigInventoryTest { */ @Nested class ChannelFiltering { - ConfigInventory inv = ConfigInventory.configStacks(Set.of(AEKeyType.items()), 2, null, false); + ConfigInventory inv = ConfigInventory.configStacks(2).supportedType(AEKeyType.items()).build(); @BeforeEach void loadMixedStacks() { @@ -55,7 +53,7 @@ void getGetKeyOnlyReturnsItems() { @Nested class TypesMode { - ConfigInventory inv = ConfigInventory.configTypes(Set.of(AEKeyType.items()), 1, null); + ConfigInventory inv = ConfigInventory.configTypes(1).supportedTypes(AEKeyType.items()).build(); @Test void amountZeroIsAllowed() { @@ -72,7 +70,7 @@ void otherAmountsAreSetToZero() { @Nested class StacksMode { - ConfigInventory inv = ConfigInventory.configStacks(Set.of(AEKeyType.items()), 1, null, false); + ConfigInventory inv = ConfigInventory.configStacks(1).supportedType(AEKeyType.items()).build(); @Test void stacksWithAmountZeroAreDropped() { diff --git a/src/test/java/appeng/util/ConfigMenuInventoryTest.java b/src/test/java/appeng/util/ConfigMenuInventoryTest.java index fd485dede81..e3cea4e10e4 100644 --- a/src/test/java/appeng/util/ConfigMenuInventoryTest.java +++ b/src/test/java/appeng/util/ConfigMenuInventoryTest.java @@ -3,7 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.List; -import java.util.Set; import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.DisplayName; @@ -57,7 +56,7 @@ Iterable fluidTests() { @Test void testFluidConfigReadsAsWrappedStackOfCount1() { - var inv = ConfigInventory.configTypes(Set.of(AEKeyType.fluids()), 1, null); + var inv = ConfigInventory.configTypes(1).supportedType(AEKeyType.fluids()).build(); inv.setStack(0, WATER); var wrappedStack = inv.createMenuWrapper().getStackInSlot(0); assertEquals(1, wrappedStack.getCount()); @@ -71,7 +70,7 @@ void testFluidConfigReadsAsWrappedStackOfCount1() { */ @Test void testItemTypeConfigReadsAsItemWithAmount1() { - var inv = ConfigInventory.configTypes(Set.of(AEKeyType.items()), 1, null); + var inv = ConfigInventory.configTypes(1).supportedType(AEKeyType.items()).build(); inv.setStack(0, ZERO_STICK); var fakeStack = inv.createMenuWrapper().getStackInSlot(0); assertEquals(Items.STICK, fakeStack.getItem()); @@ -94,7 +93,7 @@ private DynamicTest test(String displayName, AEKeyType channel, ItemStack insert return DynamicTest.dynamicTest( displayName, () -> { - var inv = ConfigInventory.configStacks(Set.of(channel), 64, null, false); + var inv = ConfigInventory.configStacks(64).supportedType(channel).build(); if (initialStack != null) { inv.setStack(0, initialStack); }