Skip to content

Commit

Permalink
feat: ✨ Changed upgrade in world interaction to allow using this from…
Browse files Browse the repository at this point in the history
… in motion mod
  • Loading branch information
P3pp3rF1y committed Jan 16, 2025
1 parent c0746cf commit 3c55cc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3c55cc4

Please sign in to comment.