diff --git a/gradle.properties b/gradle.properties index 9c6b307..ba5ec31 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false mod_id=sophisticatedstorageinmotion mod_group_id=sophisticatedstorageinmotion -mod_version=0.7.3 +mod_version=0.7.4 sonar_project_key=sophisticatedstorageinmotion:SophisticatedStorageInMotion github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedStorageInMotion @@ -25,5 +25,5 @@ jei_mc_version=1.20.1-forge jei_version=15.19.5.99 jei_version_range=[19.9.0,) sc_version=[1.20.1-1.0.8,1.20.4) -ss_version=[1.20.1-1.2.4,1.20.4) +ss_version=[1.20.1-1.2.5,1.20.4) parchment_version=2023.09.03-1.20.1 \ No newline at end of file diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/common/CommonEventHandler.java b/src/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/common/CommonEventHandler.java index 57af938..5b8ec82 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/common/CommonEventHandler.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/common/CommonEventHandler.java @@ -13,10 +13,13 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.IEventBus; +import net.p3pp3rf1y.sophisticatedcore.upgrades.UpgradeItemBase; import net.p3pp3rf1y.sophisticatedcore.util.NBTHelper; import net.p3pp3rf1y.sophisticatedstorage.Config; import net.p3pp3rf1y.sophisticatedstorage.block.ItemContentsStorage; +import net.p3pp3rf1y.sophisticatedstorage.block.StorageBlockBase; import net.p3pp3rf1y.sophisticatedstorage.block.StorageBlockEntity; import net.p3pp3rf1y.sophisticatedstorage.block.StorageWrapper; import net.p3pp3rf1y.sophisticatedstorage.init.ModItems; @@ -41,6 +44,24 @@ public static void registerHandlers() { eventBus.addListener(StorageToolHandler::onStorageToolInteract); eventBus.addListener(CommonEventHandler::onPacked); eventBus.addListener(CommonEventHandler::onPaintbrushInteract); + eventBus.addListener(CommonEventHandler::onStorageUpgradeInteract); + } + + private static void onStorageUpgradeInteract(Event event) { + if (!(event instanceof PlayerInteractEvent.EntityInteract entityInteractEvent)) { + return; + } + + Player player = entityInteractEvent.getEntity(); + ItemStack itemInHand = player.getItemInHand(entityInteractEvent.getHand()); + if (!(entityInteractEvent.getTarget() instanceof IMovingStorageEntity movingStorage) || !(itemInHand.getItem() instanceof UpgradeItemBase)) { + return; + } + + if (StorageBlockBase.tryAddSingleUpgrade(player, entityInteractEvent.getHand(), itemInHand, movingStorage.getStorageHolder().getStorageWrapper())) { + entityInteractEvent.setCanceled(true); + entityInteractEvent.setCancellationResult(InteractionResult.SUCCESS); + } } private static void onPaintbrushInteract(PlayerInteractEvent.EntityInteract event) { diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/entity/MovingStorageWrapper.java b/src/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/entity/MovingStorageWrapper.java index ba3e475..414caef 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/entity/MovingStorageWrapper.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/entity/MovingStorageWrapper.java @@ -392,10 +392,10 @@ public String getStorageType() { return ChestBlockEntity.STORAGE_TYPE; } else if (blockItem.getBlock() instanceof ShulkerBoxBlock) { return ShulkerBoxBlockEntity.STORAGE_TYPE; - } else if (blockItem.getBlock() instanceof BarrelBlock) { - return BarrelBlockEntity.STORAGE_TYPE; } else if (blockItem.getBlock() instanceof LimitedBarrelBlock) { return LimitedBarrelBlockEntity.STORAGE_TYPE; + } else if (blockItem.getBlock() instanceof BarrelBlock) { + return BarrelBlockEntity.STORAGE_TYPE; } return "undefined";