Skip to content

Commit

Permalink
feat: ✨ Upgrades can now be applied to storage minecarts using right-…
Browse files Browse the repository at this point in the history
…click in-world
  • Loading branch information
P3pp3rF1y committed Jan 16, 2025
1 parent ac641f6 commit 0396c15
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 0396c15

Please sign in to comment.