From 2fe23df4d814e50a03cfc18e277d8b7407843f03 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Sun, 4 Feb 2024 13:24:11 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20configuration=20to=20?= =?UTF-8?q?limit=20number=20of=20upgrades=20of=20type=20in=20storage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../sophisticatedbackpacks/Config.java | 104 ++++++++++++++++-- .../SophisticatedBackpacks.java | 2 +- .../backpack/wrapper/BackpackWrapper.java | 46 ++++---- .../backpack/wrapper/IBackpackWrapper.java | 18 ++- .../compat/chipped/ChippedCompat.java | 15 +-- .../sophisticatedbackpacks/init/ModItems.java | 91 +++++++-------- .../upgrades/anvil/AnvilUpgradeItem.java | 4 +- .../upgrades/deposit/DepositUpgradeItem.java | 3 +- .../everlasting/EverlastingUpgradeItem.java | 5 +- .../inception/InceptionUpgradeItem.java | 10 +- .../upgrades/refill/RefillUpgradeItem.java | 5 +- .../upgrades/restock/RestockUpgradeItem.java | 3 +- .../toolswapper/ToolSwapperUpgradeItem.java | 8 +- src/main/resources/META-INF/mods.toml | 2 +- 15 files changed, 214 insertions(+), 104 deletions(-) diff --git a/gradle.properties b/gradle.properties index 03c5f686..54f15baa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,5 +13,5 @@ crafting_tweaks_cf_file_id=3914007 chipped_cf_file_id=4558849 ctm_cf_file_id=4393695 resourcefullib_cf_file_id=4477753 -sc_version=1.19.2-0.5.110.+ +sc_version=1.19.2-0.5.113.+ parchment_version=1.18.2-2022.06.05-1.19 \ No newline at end of file diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java index 28ff80e1..c0661407 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java @@ -6,39 +6,39 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.storage.loot.BuiltInLootTables; import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.event.config.ModConfigEvent; import net.minecraftforge.registries.ForgeRegistries; import net.p3pp3rf1y.sophisticatedbackpacks.backpack.BackpackItem; +import net.p3pp3rf1y.sophisticatedbackpacks.init.ModItems; import net.p3pp3rf1y.sophisticatedcore.upgrades.FilteredUpgradeConfig; +import net.p3pp3rf1y.sophisticatedcore.upgrades.IUpgradeCountLimitConfig; +import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeGroup; import net.p3pp3rf1y.sophisticatedcore.upgrades.battery.BatteryUpgradeConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.AutoCookingUpgradeConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.CookingUpgradeConfig; +import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.ICookingUpgrade; import net.p3pp3rf1y.sophisticatedcore.upgrades.magnet.MagnetUpgradeConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.pump.PumpUpgradeConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.stack.StackUpgradeConfig; +import net.p3pp3rf1y.sophisticatedcore.upgrades.stack.StackUpgradeItem; import net.p3pp3rf1y.sophisticatedcore.upgrades.tank.TankUpgradeConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.voiding.VoidUpgradeConfig; import net.p3pp3rf1y.sophisticatedcore.upgrades.xppump.XpPumpUpgradeConfig; import org.apache.commons.lang3.tuple.Pair; import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; -@SuppressWarnings("java:S1192") //don't complain about repeated config names if two upgrades happen to have the same setting +@SuppressWarnings("java:S1192") +//don't complain about repeated config names if two upgrades happen to have the same setting public class Config { private static final String REGISTRY_NAME_MATCHER = "([a-z0-9_.-]+:[a-z0-9_/.-]+)"; - private Config() {} + private Config() { + } public static final Server SERVER; public static final ForgeConfigSpec SERVER_SPEC; @@ -103,12 +103,29 @@ public static class Server { public final PumpUpgradeConfig pumpUpgrade; public final XpPumpUpgradeConfig xpPumpUpgrade; public final NerfsConfig nerfsConfig; + public final MaxUgradesPerStorageConfig maxUpgradesPerStorage; + public void initListeners(IEventBus modBus) { + modBus.addListener(this::onConfigReload); + modBus.addListener(this::onConfigLoad); + } - @SuppressWarnings("unused") //need the Event parameter for forge reflection to understand what event this listens to + @SuppressWarnings("unused") + //need the Event parameter for forge reflection to understand what event this listens to public void onConfigReload(ModConfigEvent.Reloading event) { + clearCache(); + } + + @SuppressWarnings("unused") + //need the Event parameter for forge reflection to understand what event this listens to + public void onConfigLoad(ModConfigEvent.Loading event) { + clearCache(); + } + + private void clearCache() { disallowedItems.initialized = false; stackUpgrade.clearNonStackableItems(); + maxUpgradesPerStorage.clearCache(); } Server(ForgeConfigSpec.Builder builder) { @@ -157,6 +174,13 @@ public void onConfigReload(ModConfigEvent.Reloading event) { xpPumpUpgrade = new XpPumpUpgradeConfig(builder); entityBackpackAdditions = new EntityBackpackAdditionsConfig(builder); nerfsConfig = new NerfsConfig(builder); + maxUpgradesPerStorage = new MaxUgradesPerStorageConfig(builder, + Map.of( + StackUpgradeItem.UPGRADE_GROUP.name(), 3, + ICookingUpgrade.UPGRADE_GROUP.name(), 1, + ModItems.JUKEBOX_UPGRADE_NAME, 1 + ) + ); itemFluidHandlerEnabled = builder.comment("Turns on/off item fluid handler of backpack in its item form. There are some dupe bugs caused by default fluid handling implementation that manifest when backpack is drained / filled in its item form in another mod's tank and the only way to prevent them is disallowing drain/fill in item form altogether").define("itemFluidHandlerEnabled", true); allowOpeningOtherPlayerBackpacks = builder.comment("Determines whether player can right click on backpack that another player is wearing to open it. If off will turn off that capability for everyone and remove related settings from backpack.").define("allowOpeningOtherPlayerBackpacks", true); @@ -166,11 +190,13 @@ public void onConfigReload(ModConfigEvent.Reloading event) { builder.pop(); } + public static class NerfsConfig { public final ForgeConfigSpec.BooleanValue tooManyBackpacksSlowness; public final ForgeConfigSpec.IntValue maxNumberOfBackpacks; public final ForgeConfigSpec.DoubleValue slownessLevelsPerAdditionalBackpack; public final ForgeConfigSpec.BooleanValue onlyWornBackpackTriggersUpgrades; + public NerfsConfig(ForgeConfigSpec.Builder builder) { builder.push("nerfs"); tooManyBackpacksSlowness = builder.comment("Determines if too many backpacks in player's inventory cause slowness to the player").define("tooManyBackpacksSlowness", false); @@ -181,6 +207,7 @@ public NerfsConfig(ForgeConfigSpec.Builder builder) { } } + public static class EntityBackpackAdditionsConfig { private static final String ENTITY_LOOT_MATCHER = "([a-z0-9_.-]+:[a-z0-9_/.-]+)\\|(null|[a-z0-9_.-]+:[a-z0-9/_.-]+)"; public final ForgeConfigSpec.DoubleValue chance; @@ -414,10 +441,63 @@ private void loadDisallowedSet() { } } } + + public static class MaxUgradesPerStorageConfig implements IUpgradeCountLimitConfig { + private final ForgeConfigSpec.ConfigValue> maxUpgradesPerStorageList; + + @Nullable + private Map maxUpgradesPerStorage = null; + + protected MaxUgradesPerStorageConfig(ForgeConfigSpec.Builder builder, Map defaultUpgradesPerStorage) { + maxUpgradesPerStorageList = builder.comment("Maximum number of upgrades of type per backpack in format of \"UpgradeRegistryName[or UpgradeGroup]|MaxNumber\"").define("maxUpgradesPerStorage", convertToList(defaultUpgradesPerStorage)); + } + + private List convertToList(Map defaultUpgradesPerStorage) { + return defaultUpgradesPerStorage.entrySet().stream().map(e -> e.getKey() + "|" + e.getValue()).collect(Collectors.toList()); + } + + public void clearCache() { + maxUpgradesPerStorage = null; + } + + @Override + public int getMaxUpgradesPerStorage(String storageType, @org.jetbrains.annotations.Nullable ResourceLocation upgradeRegistryName) { + if (maxUpgradesPerStorage == null) { + initMaxUpgradesPerStorage(); + } + if (upgradeRegistryName == null) { + return Integer.MAX_VALUE; + } + + return maxUpgradesPerStorage.getOrDefault(upgradeRegistryName.getPath(), Integer.MAX_VALUE); + } + + private void initMaxUpgradesPerStorage() { + maxUpgradesPerStorage = new HashMap<>(); + for (String mapping : maxUpgradesPerStorageList.get()) { + String[] upgradeMax = mapping.split("\\|"); + if (upgradeMax.length < 2) { + continue; + } + String name = upgradeMax[0]; + int max = Integer.parseInt(upgradeMax[1]); + maxUpgradesPerStorage.put(name, max); + } + } + + @Override + public int getMaxUpgradesInGroupPerStorage(String storageType, UpgradeGroup upgradeGroup) { + if (maxUpgradesPerStorage == null) { + initMaxUpgradesPerStorage(); + } + return maxUpgradesPerStorage.getOrDefault(upgradeGroup.name(), Integer.MAX_VALUE); + } + } } public static class Common { public final ForgeConfigSpec.BooleanValue chestLootEnabled; + Common(ForgeConfigSpec.Builder builder) { builder.comment("Common Settings").push("common"); diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/SophisticatedBackpacks.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/SophisticatedBackpacks.java index 23206313..3c8cc960 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/SophisticatedBackpacks.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/SophisticatedBackpacks.java @@ -55,7 +55,7 @@ public SophisticatedBackpacks() { modBus.addListener(SophisticatedBackpacks::setup); modBus.addListener(DataGenerators::gatherData); - modBus.addListener(Config.SERVER::onConfigReload); + Config.SERVER.initListeners(modBus); modBus.addListener(CapabilityBackpackWrapper::onRegister); modBus.addListener(SophisticatedBackpacks::clientSetup); ModLoot.init(modBus); diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java index caeac87f..295cf8e6 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/BackpackWrapper.java @@ -4,6 +4,7 @@ import net.minecraft.nbt.FloatTag; import net.minecraft.nbt.IntTag; import net.minecraft.nbt.StringTag; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; @@ -31,20 +32,10 @@ import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeHandler; import net.p3pp3rf1y.sophisticatedcore.upgrades.stack.StackUpgradeItem; import net.p3pp3rf1y.sophisticatedcore.upgrades.tank.TankUpgradeItem; -import net.p3pp3rf1y.sophisticatedcore.util.InventoryHelper; -import net.p3pp3rf1y.sophisticatedcore.util.InventorySorter; -import net.p3pp3rf1y.sophisticatedcore.util.LootHelper; -import net.p3pp3rf1y.sophisticatedcore.util.NBTHelper; -import net.p3pp3rf1y.sophisticatedcore.util.RandHelper; +import net.p3pp3rf1y.sophisticatedcore.util.*; import javax.annotation.Nullable; -import java.util.Comparator; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.function.IntConsumer; public class BackpackWrapper implements IBackpackWrapper { @@ -62,8 +53,10 @@ public class BackpackWrapper implements IBackpackWrapper { private static final String COLUMNS_TAKEN_TAG = "columnsTaken"; private final ItemStack backpack; - private Runnable backpackSaveHandler = () -> {}; - private Runnable inventorySlotChangeHandler = () -> {}; + private Runnable backpackSaveHandler = () -> { + }; + private Runnable inventorySlotChangeHandler = () -> { + }; @Nullable private InventoryHandler handler = null; @@ -84,10 +77,13 @@ public class BackpackWrapper implements IBackpackWrapper { private final BackpackRenderInfo renderInfo; - private IntConsumer onSlotsChange = diff -> {}; + private IntConsumer onSlotsChange = diff -> { + }; - private Runnable onInventoryHandlerRefresh = () -> {}; - private Runnable upgradeCachesInvalidatedHandler = () -> {}; + private Runnable onInventoryHandlerRefresh = () -> { + }; + private Runnable upgradeCachesInvalidatedHandler = () -> { + }; public BackpackWrapper(ItemStack backpack) { this.backpack = backpack; @@ -471,7 +467,8 @@ public void registerOnSlotsChangeListener(IntConsumer onSlotsChange) { @Override public void unregisterOnSlotsChangeListener() { - onSlotsChange = diff -> {}; + onSlotsChange = diff -> { + }; } @Override @@ -526,11 +523,22 @@ public void registerOnInventoryHandlerRefreshListener(Runnable onInventoryHandle @Override public void unregisterOnInventoryHandlerRefreshListener() { - onInventoryHandlerRefresh = () -> {}; + onInventoryHandlerRefresh = () -> { + }; } @Override public ItemStack getWrappedStorageStack() { return getBackpack(); } + + @Override + public String getStorageType() { + return "backpack"; + } + + @Override + public Component getDisplayName() { + return getBackpack().getHoverName(); + } } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/IBackpackWrapper.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/IBackpackWrapper.java index 871d715b..b7f2f694 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/IBackpackWrapper.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/backpack/wrapper/IBackpackWrapper.java @@ -55,7 +55,8 @@ class Noop extends NoopStorageWrapper implements IBackpackWrapper { public static final Noop INSTANCE = new Noop(); private final ItemStack backpack = new ItemStack(ModItems.BACKPACK.get()); - private final BackpackSettingsHandler settingsHandler = new BackpackSettingsHandler(this, new CompoundTag(), () -> {}); + private final BackpackSettingsHandler settingsHandler = new BackpackSettingsHandler(this, new CompoundTag(), () -> { + }); @Override public BackpackSettingsHandler getSettingsHandler() { @@ -76,5 +77,20 @@ public ItemStack cloneBackpack() { public void copyDataTo(IStorageWrapper otherStorageWrapper) { //noop } + + @Override + public void setSlotNumbers(int numberOfInventorySlots, int numberOfUpgradeSlots) { + //noop + } + + @Override + public void setLoot(ResourceLocation lootTableName, float lootPercentage) { + //noop + } + + @Override + public void setContentsUuid(UUID storageUuid) { + //noop + } } } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/chipped/ChippedCompat.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/chipped/ChippedCompat.java index b665f67e..ef006c1b 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/chipped/ChippedCompat.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/chipped/ChippedCompat.java @@ -15,6 +15,7 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegisterEvent; import net.minecraftforge.registries.RegistryObject; +import net.p3pp3rf1y.sophisticatedbackpacks.Config; import net.p3pp3rf1y.sophisticatedbackpacks.SophisticatedBackpacks; import net.p3pp3rf1y.sophisticatedbackpacks.client.gui.SBPButtonDefinitions; import net.p3pp3rf1y.sophisticatedbackpacks.compat.jei.SBPPlugin; @@ -36,19 +37,19 @@ public class ChippedCompat implements ICompat { public static final RegistryObject BOTANIST_WORKBENCH_UPGRADE = ModItems.ITEMS.register("chipped/botanist_workbench_upgrade", - () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.BOTANIST_WORKBENCH_TYPE)); + () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.BOTANIST_WORKBENCH_TYPE, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject GLASSBLOWER_WORKBENCH_UPGRADE = ModItems.ITEMS.register("chipped/glassblower_workbench_upgrade", - () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.GLASSBLOWER_TYPE)); + () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.GLASSBLOWER_TYPE, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject CARPENTER_WORKBENCH_UPGRADE = ModItems.ITEMS.register("chipped/carpenter_workbench_upgrade", - () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.CARPENTERS_TABLE_TYPE)); + () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.CARPENTERS_TABLE_TYPE, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject SHEPHERD_WORKBENCH_UPGRADE = ModItems.ITEMS.register("chipped/shepherd_workbench_upgrade", - () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.LOOM_TABLE_TYPE)); + () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.LOOM_TABLE_TYPE, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject MASON_WORKBENCH_UPGRADE = ModItems.ITEMS.register("chipped/mason_workbench_upgrade", - () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.MASON_TABLE_TYPE)); + () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.MASON_TABLE_TYPE, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject PHILOSOPHER_WORKBENCH_UPGRADE = ModItems.ITEMS.register("chipped/philosopher_workbench_upgrade", - () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.ALCHEMY_BENCH_TYPE)); + () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.ALCHEMY_BENCH_TYPE, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject TINKERER_WORKBENCH_UPGRADE = ModItems.ITEMS.register("chipped/tinkerer_workbench_upgrade", - () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.TINKERING_TABLE_TYPE)); + () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.TINKERING_TABLE_TYPE, Config.SERVER.maxUpgradesPerStorage)); @Override public void init() { diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java index 36808c6f..15ee2cd1 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java @@ -84,27 +84,12 @@ import net.p3pp3rf1y.sophisticatedcore.common.gui.UpgradeContainerRegistry; import net.p3pp3rf1y.sophisticatedcore.common.gui.UpgradeContainerType; import net.p3pp3rf1y.sophisticatedcore.upgrades.ContentsFilteredUpgradeContainer; -import net.p3pp3rf1y.sophisticatedcore.upgrades.battery.BatteryInventoryPart; -import net.p3pp3rf1y.sophisticatedcore.upgrades.battery.BatteryUpgradeContainer; -import net.p3pp3rf1y.sophisticatedcore.upgrades.battery.BatteryUpgradeItem; -import net.p3pp3rf1y.sophisticatedcore.upgrades.battery.BatteryUpgradeTab; -import net.p3pp3rf1y.sophisticatedcore.upgrades.battery.BatteryUpgradeWrapper; +import net.p3pp3rf1y.sophisticatedcore.upgrades.battery.*; import net.p3pp3rf1y.sophisticatedcore.upgrades.compacting.CompactingUpgradeContainer; import net.p3pp3rf1y.sophisticatedcore.upgrades.compacting.CompactingUpgradeItem; import net.p3pp3rf1y.sophisticatedcore.upgrades.compacting.CompactingUpgradeTab; import net.p3pp3rf1y.sophisticatedcore.upgrades.compacting.CompactingUpgradeWrapper; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.AutoBlastingUpgradeItem; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.AutoCookingUpgradeContainer; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.AutoCookingUpgradeTab; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.AutoCookingUpgradeWrapper; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.AutoSmeltingUpgradeItem; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.AutoSmokingUpgradeItem; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.BlastingUpgradeItem; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.CookingUpgradeContainer; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.CookingUpgradeTab; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.CookingUpgradeWrapper; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.SmeltingUpgradeItem; -import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.SmokingUpgradeItem; +import net.p3pp3rf1y.sophisticatedcore.upgrades.cooking.*; import net.p3pp3rf1y.sophisticatedcore.upgrades.crafting.CraftingUpgradeContainer; import net.p3pp3rf1y.sophisticatedcore.upgrades.crafting.CraftingUpgradeItem; import net.p3pp3rf1y.sophisticatedcore.upgrades.crafting.CraftingUpgradeTab; @@ -135,11 +120,7 @@ import net.p3pp3rf1y.sophisticatedcore.upgrades.stonecutter.StonecutterUpgradeItem; import net.p3pp3rf1y.sophisticatedcore.upgrades.stonecutter.StonecutterUpgradeTab; import net.p3pp3rf1y.sophisticatedcore.upgrades.stonecutter.StonecutterUpgradeWrapper; -import net.p3pp3rf1y.sophisticatedcore.upgrades.tank.TankInventoryPart; -import net.p3pp3rf1y.sophisticatedcore.upgrades.tank.TankUpgradeContainer; -import net.p3pp3rf1y.sophisticatedcore.upgrades.tank.TankUpgradeItem; -import net.p3pp3rf1y.sophisticatedcore.upgrades.tank.TankUpgradeTab; -import net.p3pp3rf1y.sophisticatedcore.upgrades.tank.TankUpgradeWrapper; +import net.p3pp3rf1y.sophisticatedcore.upgrades.tank.*; import net.p3pp3rf1y.sophisticatedcore.upgrades.voiding.VoidUpgradeContainer; import net.p3pp3rf1y.sophisticatedcore.upgrades.voiding.VoidUpgradeItem; import net.p3pp3rf1y.sophisticatedcore.upgrades.voiding.VoidUpgradeTab; @@ -151,7 +132,8 @@ import net.p3pp3rf1y.sophisticatedcore.util.ItemBase; public class ModItems { - private ModItems() {} + private ModItems() { + } public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, SophisticatedBackpacks.MOD_ID); private static final DeferredRegister> MENU_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, SophisticatedBackpacks.MOD_ID); @@ -173,29 +155,29 @@ private ModItems() {} public static final TagKey BACKPACK_UPGRADE_TAG = TagKey.create(Registry.ITEM_REGISTRY, BACKPACK_UPGRADE_TAG_NAME); public static final RegistryObject PICKUP_UPGRADE = ITEMS.register("pickup_upgrade", - () -> new PickupUpgradeItem(Config.SERVER.pickupUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP)); + () -> new PickupUpgradeItem(Config.SERVER.pickupUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject ADVANCED_PICKUP_UPGRADE = ITEMS.register("advanced_pickup_upgrade", - () -> new PickupUpgradeItem(Config.SERVER.advancedPickupUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP)); + () -> new PickupUpgradeItem(Config.SERVER.advancedPickupUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject FILTER_UPGRADE = ITEMS.register("filter_upgrade", - () -> new FilterUpgradeItem(Config.SERVER.filterUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP)); + () -> new FilterUpgradeItem(Config.SERVER.filterUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject ADVANCED_FILTER_UPGRADE = ITEMS.register("advanced_filter_upgrade", - () -> new FilterUpgradeItem(Config.SERVER.advancedFilterUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP)); + () -> new FilterUpgradeItem(Config.SERVER.advancedFilterUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject MAGNET_UPGRADE = ITEMS.register("magnet_upgrade", - () -> new MagnetUpgradeItem(Config.SERVER.magnetUpgrade.magnetRange::get, Config.SERVER.magnetUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP)); + () -> new MagnetUpgradeItem(Config.SERVER.magnetUpgrade.magnetRange::get, Config.SERVER.magnetUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject ADVANCED_MAGNET_UPGRADE = ITEMS.register("advanced_magnet_upgrade", - () -> new MagnetUpgradeItem(Config.SERVER.advancedMagnetUpgrade.magnetRange::get, Config.SERVER.advancedMagnetUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP)); + () -> new MagnetUpgradeItem(Config.SERVER.advancedMagnetUpgrade.magnetRange::get, Config.SERVER.advancedMagnetUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject FEEDING_UPGRADE = ITEMS.register("feeding_upgrade", - () -> new FeedingUpgradeItem(Config.SERVER.feedingUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP)); + () -> new FeedingUpgradeItem(Config.SERVER.feedingUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject ADVANCED_FEEDING_UPGRADE = ITEMS.register("advanced_feeding_upgrade", - () -> new FeedingUpgradeItem(Config.SERVER.advancedFeedingUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP)); + () -> new FeedingUpgradeItem(Config.SERVER.advancedFeedingUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject COMPACTING_UPGRADE = ITEMS.register("compacting_upgrade", - () -> new CompactingUpgradeItem(false, Config.SERVER.compactingUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP)); + () -> new CompactingUpgradeItem(false, Config.SERVER.compactingUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject ADVANCED_COMPACTING_UPGRADE = ITEMS.register("advanced_compacting_upgrade", - () -> new CompactingUpgradeItem(true, Config.SERVER.advancedCompactingUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP)); + () -> new CompactingUpgradeItem(true, Config.SERVER.advancedCompactingUpgrade.filterSlots::get, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject VOID_UPGRADE = ITEMS.register("void_upgrade", - () -> new VoidUpgradeItem(Config.SERVER.voidUpgrade, SophisticatedBackpacks.ITEM_GROUP)); + () -> new VoidUpgradeItem(Config.SERVER.voidUpgrade, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject ADVANCED_VOID_UPGRADE = ITEMS.register("advanced_void_upgrade", - () -> new VoidUpgradeItem(Config.SERVER.advancedVoidUpgrade, SophisticatedBackpacks.ITEM_GROUP)); + () -> new VoidUpgradeItem(Config.SERVER.advancedVoidUpgrade, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject RESTOCK_UPGRADE = ITEMS.register("restock_upgrade", () -> new RestockUpgradeItem(Config.SERVER.restockUpgrade.filterSlots::get)); public static final RegistryObject ADVANCED_RESTOCK_UPGRADE = ITEMS.register("advanced_restock_upgrade", @@ -213,40 +195,41 @@ private ModItems() {} public static final RegistryObject EVERLASTING_UPGRADE = ITEMS.register("everlasting_upgrade", EverlastingUpgradeItem::new); public static final RegistryObject SMELTING_UPGRADE = ITEMS.register("smelting_upgrade", - () -> new SmeltingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.smeltingUpgrade)); + () -> new SmeltingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.smeltingUpgrade, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject AUTO_SMELTING_UPGRADE = ITEMS.register("auto_smelting_upgrade", - () -> new AutoSmeltingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.autoSmeltingUpgrade)); + () -> new AutoSmeltingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.autoSmeltingUpgrade, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject SMOKING_UPGRADE = ITEMS.register("smoking_upgrade", - () -> new SmokingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.smokingUpgrade)); + () -> new SmokingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.smokingUpgrade, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject AUTO_SMOKING_UPGRADE = ITEMS.register("auto_smoking_upgrade", - () -> new AutoSmokingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.autoSmokingUpgrade)); + () -> new AutoSmokingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.autoSmokingUpgrade, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject BLASTING_UPGRADE = ITEMS.register("blasting_upgrade", - () -> new BlastingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.blastingUpgrade)); + () -> new BlastingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.blastingUpgrade, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject AUTO_BLASTING_UPGRADE = ITEMS.register("auto_blasting_upgrade", - () -> new AutoBlastingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.autoBlastingUpgrade)); + () -> new AutoBlastingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.autoBlastingUpgrade, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject CRAFTING_UPGRADE = ITEMS.register("crafting_upgrade", - () -> new CraftingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP)); + () -> new CraftingUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject STONECUTTER_UPGRADE = ITEMS.register("stonecutter_upgrade", - () -> new StonecutterUpgradeItem(SophisticatedBackpacks.ITEM_GROUP)); + () -> new StonecutterUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject STACK_UPGRADE_TIER_1 = ITEMS.register("stack_upgrade_tier_1", () -> - new StackUpgradeItem(2, SophisticatedBackpacks.ITEM_GROUP)); + new StackUpgradeItem(2, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject STACK_UPGRADE_TIER_2 = ITEMS.register("stack_upgrade_tier_2", () -> - new StackUpgradeItem(4, SophisticatedBackpacks.ITEM_GROUP)); + new StackUpgradeItem(4, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject STACK_UPGRADE_TIER_3 = ITEMS.register("stack_upgrade_tier_3", () -> - new StackUpgradeItem(8, SophisticatedBackpacks.ITEM_GROUP)); + new StackUpgradeItem(8, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject STACK_UPGRADE_TIER_4 = ITEMS.register("stack_upgrade_tier_4", () -> - new StackUpgradeItem(16, SophisticatedBackpacks.ITEM_GROUP)); - public static final RegistryObject JUKEBOX_UPGRADE = ITEMS.register("jukebox_upgrade", - () -> new JukeboxUpgradeItem(SophisticatedBackpacks.ITEM_GROUP)); + new StackUpgradeItem(16, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); + public static final String JUKEBOX_UPGRADE_NAME = "jukebox_upgrade"; + public static final RegistryObject JUKEBOX_UPGRADE = ITEMS.register(JUKEBOX_UPGRADE_NAME, + () -> new JukeboxUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject TOOL_SWAPPER_UPGRADE = ITEMS.register("tool_swapper_upgrade", () -> new ToolSwapperUpgradeItem(false, false)); public static final RegistryObject ADVANCED_TOOL_SWAPPER_UPGRADE = ITEMS.register("advanced_tool_swapper_upgrade", () -> new ToolSwapperUpgradeItem(true, true)); - public static final RegistryObject TANK_UPGRADE = ITEMS.register("tank_upgrade", () -> new TankUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.tankUpgrade)); - public static final RegistryObject BATTERY_UPGRADE = ITEMS.register("battery_upgrade", () -> new BatteryUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.batteryUpgrade)); - public static final RegistryObject PUMP_UPGRADE = ITEMS.register("pump_upgrade", () -> new PumpUpgradeItem(false, false, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.pumpUpgrade)); - public static final RegistryObject ADVANCED_PUMP_UPGRADE = ITEMS.register("advanced_pump_upgrade", () -> new PumpUpgradeItem(true, true, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.pumpUpgrade)); - public static final RegistryObject XP_PUMP_UPGRADE = ITEMS.register("xp_pump_upgrade", () -> new XpPumpUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.xpPumpUpgrade)); + public static final RegistryObject TANK_UPGRADE = ITEMS.register("tank_upgrade", () -> new TankUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.tankUpgrade, Config.SERVER.maxUpgradesPerStorage)); + public static final RegistryObject BATTERY_UPGRADE = ITEMS.register("battery_upgrade", () -> new BatteryUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.batteryUpgrade, Config.SERVER.maxUpgradesPerStorage)); + public static final RegistryObject PUMP_UPGRADE = ITEMS.register("pump_upgrade", () -> new PumpUpgradeItem(false, false, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.pumpUpgrade, Config.SERVER.maxUpgradesPerStorage)); + public static final RegistryObject ADVANCED_PUMP_UPGRADE = ITEMS.register("advanced_pump_upgrade", () -> new PumpUpgradeItem(true, true, SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.pumpUpgrade, Config.SERVER.maxUpgradesPerStorage)); + public static final RegistryObject XP_PUMP_UPGRADE = ITEMS.register("xp_pump_upgrade", () -> new XpPumpUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.xpPumpUpgrade, Config.SERVER.maxUpgradesPerStorage)); public static final RegistryObject ANVIL_UPGRADE = ITEMS.register("anvil_upgrade", () -> new AnvilUpgradeItem(SophisticatedBackpacks.ITEM_GROUP)); public static final RegistryObject UPGRADE_BASE = ITEMS.register("upgrade_base", () -> new ItemBase(new Item.Properties().stacksTo(16), SophisticatedBackpacks.ITEM_GROUP)); diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeItem.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeItem.java index c2d5cbc3..5e763307 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeItem.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeItem.java @@ -1,13 +1,15 @@ package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.anvil; import net.minecraft.world.item.CreativeModeTab; +import net.p3pp3rf1y.sophisticatedbackpacks.Config; import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase; import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeType; public class AnvilUpgradeItem extends UpgradeItemBase { private static final UpgradeType TYPE = new UpgradeType<>(AnvilUpgradeWrapper::new); + public AnvilUpgradeItem(CreativeModeTab itemGroup) { - super(itemGroup); + super(itemGroup, Config.SERVER.maxUpgradesPerStorage); } @Override diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/deposit/DepositUpgradeItem.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/deposit/DepositUpgradeItem.java index c30466b4..aa03e702 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/deposit/DepositUpgradeItem.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/deposit/DepositUpgradeItem.java @@ -1,5 +1,6 @@ package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.deposit; +import net.p3pp3rf1y.sophisticatedbackpacks.Config; import net.p3pp3rf1y.sophisticatedbackpacks.SophisticatedBackpacks; import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase; import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeType; @@ -11,7 +12,7 @@ public class DepositUpgradeItem extends UpgradeItemBase { private final IntSupplier filterSlotCount; public DepositUpgradeItem(IntSupplier filterSlotCount) { - super(SophisticatedBackpacks.ITEM_GROUP); + super(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage); this.filterSlotCount = filterSlotCount; } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/everlasting/EverlastingUpgradeItem.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/everlasting/EverlastingUpgradeItem.java index 2a71d1fc..6848554a 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/everlasting/EverlastingUpgradeItem.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/everlasting/EverlastingUpgradeItem.java @@ -1,6 +1,7 @@ package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.everlasting; import net.minecraft.world.item.ItemStack; +import net.p3pp3rf1y.sophisticatedbackpacks.Config; import net.p3pp3rf1y.sophisticatedbackpacks.SophisticatedBackpacks; import net.p3pp3rf1y.sophisticatedcore.api.IStorageWrapper; import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase; @@ -12,7 +13,9 @@ public class EverlastingUpgradeItem extends UpgradeItemBase { public static final UpgradeType TYPE = new UpgradeType<>(Wrapper::new); - public EverlastingUpgradeItem() {super(SophisticatedBackpacks.ITEM_GROUP);} + public EverlastingUpgradeItem() { + super(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage); + } @Override public UpgradeType getType() { diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/inception/InceptionUpgradeItem.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/inception/InceptionUpgradeItem.java index 7a5c9151..ddc78848 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/inception/InceptionUpgradeItem.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/inception/InceptionUpgradeItem.java @@ -1,6 +1,7 @@ package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.inception; import net.minecraft.world.item.ItemStack; +import net.p3pp3rf1y.sophisticatedbackpacks.Config; import net.p3pp3rf1y.sophisticatedbackpacks.SophisticatedBackpacks; import net.p3pp3rf1y.sophisticatedbackpacks.backpack.BackpackItem; import net.p3pp3rf1y.sophisticatedbackpacks.client.gui.SBPTranslationHelper; @@ -17,7 +18,9 @@ public class InceptionUpgradeItem extends UpgradeItemBase { public static final UpgradeType TYPE = new UpgradeType<>(InceptionUpgradeWrapper::new); - public InceptionUpgradeItem() {super(SophisticatedBackpacks.ITEM_GROUP);} + public InceptionUpgradeItem() { + super(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage); + } @Override public UpgradeType getType() { @@ -26,6 +29,11 @@ public UpgradeType getType() { @Override public UpgradeSlotChangeResult canAddUpgradeTo(IStorageWrapper storageWrapper, ItemStack upgradeStack, boolean firstLevelStorage, boolean isClientSide) { + UpgradeSlotChangeResult result = super.canAddUpgradeTo(storageWrapper, upgradeStack, firstLevelStorage, isClientSide); + if (!result.isSuccessful()) { + return result; + } + if (!firstLevelStorage) { return new UpgradeSlotChangeResult.Fail(SBPTranslationHelper.INSTANCE.translError("add.inception_sub_backpack"), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()); } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/refill/RefillUpgradeItem.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/refill/RefillUpgradeItem.java index 1c4a27d8..8e320897 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/refill/RefillUpgradeItem.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/refill/RefillUpgradeItem.java @@ -1,5 +1,6 @@ package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.refill; +import net.p3pp3rf1y.sophisticatedbackpacks.Config; import net.p3pp3rf1y.sophisticatedbackpacks.SophisticatedBackpacks; import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase; import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeType; @@ -10,10 +11,10 @@ public class RefillUpgradeItem extends UpgradeItemBase { private static final UpgradeType TYPE = new UpgradeType<>(RefillUpgradeWrapper::new); private final IntSupplier filterSlotCount; private final boolean targetSlotSelection; - private boolean supportsBlockPick; + private final boolean supportsBlockPick; public RefillUpgradeItem(IntSupplier filterSlotCount, boolean targetSlotSelection, boolean supportsBlockPick) { - super(SophisticatedBackpacks.ITEM_GROUP); + super(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage); this.filterSlotCount = filterSlotCount; this.targetSlotSelection = targetSlotSelection; this.supportsBlockPick = supportsBlockPick; diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/restock/RestockUpgradeItem.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/restock/RestockUpgradeItem.java index 75858a34..5fae2dbc 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/restock/RestockUpgradeItem.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/restock/RestockUpgradeItem.java @@ -1,5 +1,6 @@ package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.restock; +import net.p3pp3rf1y.sophisticatedbackpacks.Config; import net.p3pp3rf1y.sophisticatedbackpacks.SophisticatedBackpacks; import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase; import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeType; @@ -11,7 +12,7 @@ public class RestockUpgradeItem extends UpgradeItemBase { private final IntSupplier filterSlotCount; public RestockUpgradeItem(IntSupplier filterSlotCount) { - super(SophisticatedBackpacks.ITEM_GROUP); + super(SophisticatedBackpacks.ITEM_GROUP, Config.SERVER.maxUpgradesPerStorage); this.filterSlotCount = filterSlotCount; } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/toolswapper/ToolSwapperUpgradeItem.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/toolswapper/ToolSwapperUpgradeItem.java index a9e18c0b..6bf8b3da 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/toolswapper/ToolSwapperUpgradeItem.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/toolswapper/ToolSwapperUpgradeItem.java @@ -1,6 +1,7 @@ package net.p3pp3rf1y.sophisticatedbackpacks.upgrades.toolswapper; import net.minecraft.world.item.ItemStack; +import net.p3pp3rf1y.sophisticatedbackpacks.Config; import net.p3pp3rf1y.sophisticatedbackpacks.SophisticatedBackpacks; import net.p3pp3rf1y.sophisticatedbackpacks.client.gui.SBPTranslationHelper; import net.p3pp3rf1y.sophisticatedcore.api.IStorageWrapper; @@ -18,7 +19,7 @@ public class ToolSwapperUpgradeItem extends UpgradeItemBase errorUpgradeSlots = new HashSet<>(); storageWrapper.getUpgradeHandler().getSlotWrappers().forEach((slot, wrapper) -> { if (wrapper instanceof ToolSwapperUpgradeWrapper) { diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index bd077b51..0ddadc9d 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -60,7 +60,7 @@ side="BOTH" [[dependencies.sophisticatedbackpacks]] modId="sophisticatedcore" #mandatory mandatory=true #mandatory -versionRange="[1.19.2-0.5.110,)" #mandatory +versionRange="[1.19.2-0.5.113,)" #mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory ordering="NONE" # Side this dependency is applied on - BOTH, CLIENT or SERVER