From 2f82171bd88307de646507e6265b1aa92303200d Mon Sep 17 00:00:00 2001 From: YouHaveTrouble Date: Thu, 26 Feb 2026 19:56:43 +0100 Subject: [PATCH] interaction types are now data driven from config (#6) --- readme.md | 16 +++++++++++++++- .../quickerstacker/QuickerStacker.java | 11 ++++++++--- .../config/QuickerStackerConfig.java | 19 ++++++++++++------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/readme.md b/readme.md index 53a61cd..5bc0827 100644 --- a/readme.md +++ b/readme.md @@ -1 +1,15 @@ -This is my test project I mess with to learn what hytale modding can do. \ No newline at end of file +## Usage + +Simply right click on any chest to offload all items that are already in the chest from your inventory into that chest. It works exactly the same as clicking the "Quick Stack" within a chest inventory. + +You can hold down the right click for a second (you will see a progress bar) to quick stack to nearby chests. + +Hytale bug: some items will prevent interaction with the chest while held, this is a current bug in hytale I can't do much about, already reported it and are only able to wait for it to be resolved. + + +## Compatibility +This mod looks through all the blocks registered in the game for specific interaction IDs to determine if a block can be +"opened". Defaults should work with any mod that uses vanilla chest interactions, but if there are any mods that add +their own chest-like blocks with custom use interaction. You can add that interaction ID to the configuration file to +enable QuickerStacker right-click interaction for those blocks as well. THIS DOES NOT GUARANTEE THAT STACKING WILL WORK +WITH THE MATCHED BLOCKS. It only enables the initial interaction to fire. diff --git a/src/main/java/me/youhavetrouble/quickerstacker/QuickerStacker.java b/src/main/java/me/youhavetrouble/quickerstacker/QuickerStacker.java index 225ca6a..0006f60 100644 --- a/src/main/java/me/youhavetrouble/quickerstacker/QuickerStacker.java +++ b/src/main/java/me/youhavetrouble/quickerstacker/QuickerStacker.java @@ -17,6 +17,8 @@ import com.hypixel.hytale.server.core.plugin.JavaPlugin; import com.hypixel.hytale.server.core.plugin.JavaPluginInit; import com.hypixel.hytale.server.core.universe.PlayerRef; import com.hypixel.hytale.server.core.universe.world.World; +import com.hypixel.hytale.server.core.util.Config; +import me.youhavetrouble.quickerstacker.config.QuickerStackerConfig; import me.youhavetrouble.quickerstacker.interaction.QuickStackInteraction; import me.youhavetrouble.quickerstacker.interaction.QuickStackToChestInteraction; import me.youhavetrouble.quickerstacker.interaction.QuickStackToNearbyChestsInteraction; @@ -30,12 +32,16 @@ import java.util.logging.Level; public class QuickerStacker extends JavaPlugin { + private final Config config = this.withConfig("QSConfig", QuickerStackerConfig.CODEC); + public QuickerStacker(@NonNullDecl JavaPluginInit init) { super(init); } @Override public void setup() { + config.save(); + this.getCodecRegistry(Interaction.CODEC) .register( "Yht_QuickerStacker_QuickStack", @@ -96,9 +102,8 @@ public class QuickerStacker extends JavaPlugin { return !event.isCancelled(); } - private static boolean isBlockContainer(BlockType blockType) { - if ("Open_Container".equals(blockType.getInteractions().get(InteractionType.Use))) return true; - return false; + private boolean isBlockContainer(BlockType blockType) { + return config.get().getQuickStackContainers().contains(blockType.getInteractions().get(InteractionType.Use)); } } diff --git a/src/main/java/me/youhavetrouble/quickerstacker/config/QuickerStackerConfig.java b/src/main/java/me/youhavetrouble/quickerstacker/config/QuickerStackerConfig.java index fe8269a..5e8c60c 100644 --- a/src/main/java/me/youhavetrouble/quickerstacker/config/QuickerStackerConfig.java +++ b/src/main/java/me/youhavetrouble/quickerstacker/config/QuickerStackerConfig.java @@ -8,22 +8,27 @@ import java.util.*; public class QuickerStackerConfig { - private String[] quickStackContainers; - private Set quickStackContainerSet; + private String[] quickStackInteractions = { + "Open_Container", + "Open_SimpleStorage", + }; + private Set quickStackInteractionSet = Set.of(quickStackInteractions); public static final BuilderCodec CODEC = BuilderCodec.builder(QuickerStackerConfig.class, QuickerStackerConfig::new) - .append(new KeyedCodec<>("quickStackContainers", Codec.STRING_ARRAY), + .append(new KeyedCodec<>("QuickStackInteractions", Codec.STRING_ARRAY), (config, value) -> { - config.quickStackContainers = value; - config.quickStackContainerSet = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(config.quickStackContainers))); + config.quickStackInteractions = value; + config.quickStackInteractionSet = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(config.quickStackInteractions))); }, - (config) -> config.quickStackContainers).add() + (config) -> config.quickStackInteractions) + .documentation("List of interaction IDs that when detected on a block will cause QuickerStacker to attempt to add its own right click quick stack interaction. This only takes `Use` interaction type.") + .add() .build(); public QuickerStackerConfig() {} public Set getQuickStackContainers() { - return quickStackContainerSet; + return quickStackInteractionSet; } }