diff --git a/gradle.properties b/gradle.properties index fb16ab3e..a1308002 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ loader_version_range=[4,) mod_id=sophisticatedstorage mod_name=Sophisticated Storage mod_license=GNU General Public License v3.0 -mod_version=1.2.4 +mod_version=1.2.5 mod_group_id=sophisticatedstorage mod_authors=P3pp3rF1y, Ridanisaurus mod_description=Fancy and functional storage containers. diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/StorageBlockBase.java b/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/StorageBlockBase.java index 677f176e..4e38afe5 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/StorageBlockBase.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/StorageBlockBase.java @@ -226,10 +226,14 @@ protected boolean tryAddUpgrade(Player player, InteractionHand hand, StorageBloc } public boolean tryAddSingleUpgrade(Player player, InteractionHand hand, StorageBlockEntity b, ItemStack itemInHand) { + return tryAddSingleUpgrade(player, hand, itemInHand, b.getStorageWrapper()); + } + + public static boolean tryAddSingleUpgrade(Player player, InteractionHand hand, ItemStack itemInHand, IStorageWrapper storageWrapper) { if (itemInHand.getItem() instanceof UpgradeItemBase upgradeItem && RegistryHelper.getRegistryName(BuiltInRegistries.ITEM, upgradeItem).map(r -> r.getNamespace().equals(SophisticatedStorage.MOD_ID)).orElse(false)) { - UpgradeHandler upgradeHandler = b.getStorageWrapper().getUpgradeHandler(); - if (upgradeItem.canAddUpgradeTo(b.getStorageWrapper(), itemInHand, true, b.getLevel().isClientSide()).successful() + UpgradeHandler upgradeHandler = storageWrapper.getUpgradeHandler(); + if (upgradeItem.canAddUpgradeTo(storageWrapper, itemInHand, true, player.level().isClientSide()).successful() && InventoryHelper.insertIntoInventory(itemInHand, upgradeHandler, true).getCount() != itemInHand.getCount()) { InventoryHelper.insertIntoInventory(itemInHand.copyWithCount(1), upgradeHandler, false); itemInHand.shrink(1);