interaction types are now data driven from config (#6)

This commit is contained in:
2026-02-26 19:56:43 +01:00
parent eec4da9362
commit 2f82171bd8
3 changed files with 35 additions and 11 deletions
+15 -1
View File
@@ -1 +1,15 @@
This is my test project I mess with to learn what hytale modding can do.
## 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.
@@ -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<QuickerStackerConfig> 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));
}
}
@@ -8,22 +8,27 @@ import java.util.*;
public class QuickerStackerConfig {
private String[] quickStackContainers;
private Set<String> quickStackContainerSet;
private String[] quickStackInteractions = {
"Open_Container",
"Open_SimpleStorage",
};
private Set<String> quickStackInteractionSet = Set.of(quickStackInteractions);
public static final BuilderCodec<QuickerStackerConfig> 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<String> getQuickStackContainers() {
return quickStackContainerSet;
return quickStackInteractionSet;
}
}