From 6fe4147c270c8679e2611a80c31e7fd74c61d687 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Thu, 1 Feb 2024 00:39:49 +0100 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20anvil=20NPE=20c?= =?UTF-8?q?rash=20in=20some=20packs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../upgrades/anvil/AnvilUpgradeContainer.java | 4 ++++ .../upgrades/anvil/AnvilUpgradeTab.java | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 24449944..1c57e142 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false minecraft_version=1.18.2 forge_version=40.1.30 -mod_version=3.19.5 +mod_version=3.19.6 jei_mc_version=1.18.2 jei_version=9.7.2.281 curios_version=1.18.2-5.0.9.1 diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeContainer.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeContainer.java index 4e46f24c..15768232 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeContainer.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeContainer.java @@ -13,6 +13,8 @@ import net.p3pp3rf1y.sophisticatedcore.common.gui.UpgradeContainerType; import net.p3pp3rf1y.sophisticatedcore.util.NBTHelper; +import javax.annotation.Nullable; + public class AnvilUpgradeContainer extends UpgradeContainerBase { private static final String DATA_SHIFT_CLICK_INTO_STORAGE = "shiftClickIntoStorage"; private final Slot resultSlot; @@ -77,6 +79,7 @@ public int getCost() { return anvilMenuDelegate.getCost(); } + @Nullable public String getItemName() { return anvilMenuDelegate.getItemName(); } @@ -95,6 +98,7 @@ public PersistableAnvilMenu(Inventory playerInventory, AnvilUpgradeWrapper wrapp initializing = false; } + @Nullable public String getItemName() { return itemName; } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeTab.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeTab.java index 3bdf1c6b..dbd21bf0 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeTab.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/upgrades/anvil/AnvilUpgradeTab.java @@ -78,8 +78,9 @@ protected void renderBg(PoseStack poseStack, Minecraft minecraft, int mouseX, in private String getInitialNameValue() { ItemStack firstItem = getContainer().getSlots().get(0).getItem(); - if (!firstItem.isEmpty() && !getContainer().getItemName().isEmpty()) { - return getContainer().getItemName(); + String itemName = getContainer().getItemName(); + if (!firstItem.isEmpty() && itemName != null && !itemName.isEmpty()) { + return itemName; } return firstItem.isEmpty() ? "" : firstItem.getHoverName().getString(); } From 637433f56bd1ff8055b2acb0c8c64368fa0cc8a3 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Sun, 4 Feb 2024 13:24:11 +0100 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20configuration=20t?= =?UTF-8?q?o=20limit=20number=20of=20upgrades=20of=20type=20in=20storage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 4 +- .../sophisticatedbackpacks/Config.java | 107 ++++++++++++++++-- .../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, 218 insertions(+), 105 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1c57e142..57f73b7f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,14 +2,14 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false minecraft_version=1.18.2 forge_version=40.1.30 -mod_version=3.19.6 +mod_version=3.19.7 jei_mc_version=1.18.2 jei_version=9.7.2.281 curios_version=1.18.2-5.0.9.1 botania_version=1.18.2-430-SNAPSHOT patchouli_version=1.18.2-66 balm_cf_file_id=3914491 -sc_version=1.18.2-0.5.110.+ +sc_version=1.18.2-0.5.113.+ crafting_tweaks_cf_file_id=3584842 chipped_cf_file_id=4293291 ctm_cf_file_id=3933537 diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java index b4dbf23e..4a595b90 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java @@ -6,39 +6,40 @@ 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; @@ -55,6 +56,7 @@ private Config() {} COMMON_SPEC = commonSpec.getRight(); COMMON = commonSpec.getLeft(); } + public static class Server { public final DisallowedItems disallowedItems; public final NoInteractionBlocks noInteractionBlocks; @@ -102,12 +104,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) { @@ -156,6 +175,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); @@ -165,11 +191,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); @@ -180,6 +208,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; @@ -413,9 +442,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 c12606cb..b0d1eae3 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/SophisticatedBackpacks.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/SophisticatedBackpacks.java @@ -54,7 +54,7 @@ public SophisticatedBackpacks() { IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus(); 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 4ffffcee..4184f49c 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; @@ -30,20 +31,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 { @@ -61,8 +52,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; @@ -83,10 +76,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; @@ -470,7 +466,8 @@ public void registerOnSlotsChangeListener(IntConsumer onSlotsChange) { @Override public void unregisterOnSlotsChangeListener() { - onSlotsChange = diff -> {}; + onSlotsChange = diff -> { + }; } @Override @@ -525,11 +522,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 6a981333..c26e4b00 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/chipped/ChippedCompat.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/chipped/ChippedCompat.java @@ -14,6 +14,7 @@ import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; 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; @@ -35,19 +36,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.MECHANIST_WORKBENCH_TYPE)); + () -> new BlockTransformationUpgradeItem(SophisticatedBackpacks.ITEM_GROUP, ModRecipeTypes.MECHANIST_WORKBENCH_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 198cda78..5ca8304e 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/init/ModItems.java @@ -83,27 +83,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; @@ -134,11 +119,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; @@ -150,7 +131,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> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, SophisticatedBackpacks.MOD_ID); @@ -172,29 +154,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", @@ -212,40 +194,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 416aabb8..da380080 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.18.2-0.5.110,)" #mandatory +versionRange = "[1.18.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