From 5e07d0c40769aadcd36161d4e35d967d74d72a8a Mon Sep 17 00:00:00 2001 From: Sakura Ryoko Date: Sat, 2 Nov 2024 17:43:42 -0400 Subject: [PATCH] Add Bundle Preview --- .../fi/dy/masa/tweakeroo/config/Configs.java | 4 +++ .../masa/tweakeroo/config/FeatureToggle.java | 1 + .../masa/tweakeroo/event/RenderHandler.java | 8 +++++ .../masa/tweakeroo/mixin/MixinBundleItem.java | 35 +++++++++++++++++++ .../assets/tweakeroo/lang/en_us.json | 7 ++++ src/main/resources/mixins.tweakeroo.json | 1 + 6 files changed, 56 insertions(+) create mode 100644 src/main/java/fi/dy/masa/tweakeroo/mixin/MixinBundleItem.java diff --git a/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java b/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java index cb5544633..032dac2bc 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java +++ b/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java @@ -51,6 +51,8 @@ public static class Generic public static final ConfigOptionList BLOCK_TYPE_BREAK_RESTRICTION_WARN = new ConfigOptionList ("blockTypeBreakRestrictionWarn", MessageOutputType.MESSAGE).apply(GENERIC_KEY); public static final ConfigInteger BREAKING_GRID_SIZE = new ConfigInteger ("breakingGridSize", 3, 1, 1000).apply(GENERIC_KEY); public static final ConfigOptionList BREAKING_RESTRICTION_MODE = new ConfigOptionList ("breakingRestrictionMode", PlacementRestrictionMode.LINE).apply(GENERIC_KEY); + public static final ConfigBoolean BUNDLE_DISPLAY_BACKGROUND_COLOR = new ConfigBoolean ("bundleDisplayBgColor", true).apply(GENERIC_KEY); + public static final ConfigBoolean BUNDLE_DISPLAY_REQUIRE_SHIFT = new ConfigBoolean ("bundleDisplayRequireShift", true).apply(GENERIC_KEY); public static final ConfigColor CHAT_BACKGROUND_COLOR = new ConfigColor ("chatBackgroundColor", "#80000000").apply(GENERIC_KEY); public static final ConfigString CHAT_TIME_FORMAT = new ConfigString ("chatTimeFormat", "[HH:mm:ss]").apply(GENERIC_KEY); public static final ConfigBoolean CLIENT_PLACEMENT_ROTATION = new ConfigBoolean ("clientPlacementRotation", true).apply(GENERIC_KEY); @@ -133,6 +135,8 @@ public static class Generic public static final ImmutableList OPTIONS = ImmutableList.of( ACCURATE_PLACEMENT_PROTOCOL_MODE, ACCURATE_PLACEMENT_PROTOCOL, + BUNDLE_DISPLAY_BACKGROUND_COLOR, + BUNDLE_DISPLAY_REQUIRE_SHIFT, CLIENT_PLACEMENT_ROTATION, DEBUG_LOGGING, FAST_LEFT_CLICK_ALLOW_TOOLS, diff --git a/src/main/java/fi/dy/masa/tweakeroo/config/FeatureToggle.java b/src/main/java/fi/dy/masa/tweakeroo/config/FeatureToggle.java index c95bbfbdf..76fd74261 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/config/FeatureToggle.java +++ b/src/main/java/fi/dy/masa/tweakeroo/config/FeatureToggle.java @@ -28,6 +28,7 @@ public enum FeatureToggle implements IHotkeyTogglable, IConfigNotifiable> cir) + { + if (FeatureToggle.TWEAK_BUNDLE_DISPLAY.getBooleanValue() && + Configs.Generic.BUNDLE_DISPLAY_REQUIRE_SHIFT.getBooleanValue() && + GuiBase.isShiftDown()) + { + cir.setReturnValue(Optional.empty()); + } + else if (FeatureToggle.TWEAK_BUNDLE_DISPLAY.getBooleanValue() && + !Configs.Generic.BUNDLE_DISPLAY_REQUIRE_SHIFT.getBooleanValue()) + { + cir.setReturnValue(Optional.empty()); + } + } +} diff --git a/src/main/resources/assets/tweakeroo/lang/en_us.json b/src/main/resources/assets/tweakeroo/lang/en_us.json index 0ba080272..e0e2a7ec9 100644 --- a/src/main/resources/assets/tweakeroo/lang/en_us.json +++ b/src/main/resources/assets/tweakeroo/lang/en_us.json @@ -7,6 +7,8 @@ "tweakeroo.config.generic.name.blockTypeBreakRestrictionWarn": "blockTypeBreakRestrictionWarn", "tweakeroo.config.generic.name.breakingGridSize": "breakingGridSize", "tweakeroo.config.generic.name.breakingRestrictionMode": "breakingRestrictionMode", + "tweakeroo.config.generic.name.bundleDisplayBgColor": "bundleDisplayBgColor", + "tweakeroo.config.generic.name.bundleDisplayRequireShift": "bundleDisplayRequireShift", "tweakeroo.config.generic.name.chatBackgroundColor": "chatBackgroundColor", "tweakeroo.config.generic.name.chatTimeFormat": "chatTimeFormat", "tweakeroo.config.generic.name.clientPlacementRotation": "clientPlacementRotation", @@ -94,6 +96,8 @@ "tweakeroo.config.generic.comment.blockTypeBreakRestrictionWarn": "Selects which type of warning message to show (if any)\nwhen the Block Type Break Restriction feature prevents breaking a block", "tweakeroo.config.generic.comment.breakingGridSize": "The grid interval size for the grid breaking mode.\nTo quickly adjust the value, scroll while\nholding down the tweak toggle keybind.", "tweakeroo.config.generic.comment.breakingRestrictionMode": "The Breaking Restriction mode to use (hotkey-selectable)", + "tweakeroo.config.generic.comment.bundleDisplayBgColor": "Enables tinting/coloring the Bundle display\nbackground texture with the dye color of the bundle", + "tweakeroo.config.generic.comment.bundleDisplayRequireShift": "Whether or not holding shift is required for the Bundle preview\n§6NOTE: Disabling this causes the Vanilla Bundle tooltip to be fully disabled.", "tweakeroo.config.generic.comment.chatBackgroundColor": "The background color for the chat messages,\nif 'tweakChatBackgroundColor' is enabled", "tweakeroo.config.generic.comment.chatTimeFormat": "The time format for chat messages, if tweakChatTimestamp is enabled\nUses the Java SimpleDateFormat format specifiers.", "tweakeroo.config.generic.comment.clientPlacementRotation": "Enable single player and client side placement rotations,\nsuch as Accurate Placement working in single player without Carpet mod", @@ -442,6 +446,7 @@ "tweakeroo.config.feature_toggle.name.tweakBlockTypeBreakRestriction": "tweakBlockTypeBreakRestriction", "tweakeroo.config.feature_toggle.name.tweakBreakingGrid": "tweakBreakingGrid", "tweakeroo.config.feature_toggle.name.tweakBreakingRestriction": "tweakBreakingRestriction", + "tweakeroo.config.feature_toggle.name.tweakBundleDisplay": "tweakBundleDisplay", "tweakeroo.config.feature_toggle.name.tweakChatBackgroundColor": "tweakChatBackgroundColor", "tweakeroo.config.feature_toggle.name.tweakChatPersistentText": "tweakChatPersistentText", "tweakeroo.config.feature_toggle.name.tweakChatTimestamp": "tweakChatTimestamp", @@ -525,6 +530,7 @@ "tweakeroo.config.feature_toggle.prettyName.tweakBlockTypeBreakRestriction": "Block Type Break Restriction", "tweakeroo.config.feature_toggle.prettyName.tweakBreakingGrid": "Breaking Grid", "tweakeroo.config.feature_toggle.prettyName.tweakBreakingRestriction": "Breaking Restriction", + "tweakeroo.config.feature_toggle.prettyName.tweakBundleDisplay": "Bundle Display", "tweakeroo.config.feature_toggle.prettyName.tweakChatBackgroundColor": "Chat Background Color", "tweakeroo.config.feature_toggle.prettyName.tweakChatPersistentText": "Chat Persistent Text", "tweakeroo.config.feature_toggle.prettyName.tweakChatTimestamp": "Chat Timestamp", @@ -608,6 +614,7 @@ "tweakeroo.config.feature_toggle.comment.tweakBlockTypeBreakRestriction": "Restricts which blocks you are able to break (manually).\nSee the corresponding 'blockBreakRestriction*' configs in the Lists category.", "tweakeroo.config.feature_toggle.comment.tweakBreakingGrid": "When enabled, you can only break blocks in\na grid pattern, with a configurable interval.\nTo quickly adjust the interval, scroll while\nholding down the tweak toggle keybind.", "tweakeroo.config.feature_toggle.comment.tweakBreakingRestriction": "Enables the Breaking Restriction mode\n (Plane, Layer, Face, Column, Line, Diagonal).\nBasically only allows you to break blocks\nin those patterns, while holding down the attack key.", + "tweakeroo.config.feature_toggle.comment.tweakBundleDisplay": "Enables rendering a preview of the Bundle contents,\nwhen you hold shift while hovering over a Bundle item", "tweakeroo.config.feature_toggle.comment.tweakChatBackgroundColor": "Overrides the default chat background color\nwith the one from Generics -> 'chatBackgroundColor'", "tweakeroo.config.feature_toggle.comment.tweakChatPersistentText": "Stores the text from the chat input text field\nand restores it when the chat is opened again", "tweakeroo.config.feature_toggle.comment.tweakChatTimestamp": "Adds timestamps to chat messages", diff --git a/src/main/resources/mixins.tweakeroo.json b/src/main/resources/mixins.tweakeroo.json index f3a5859c5..3ed410899 100644 --- a/src/main/resources/mixins.tweakeroo.json +++ b/src/main/resources/mixins.tweakeroo.json @@ -24,6 +24,7 @@ "MixinBlockItem", "MixinBossBarHud", "MixinBuiltChunk", + "MixinBundleItem", "MixinChatHud", "MixinChatScreen", "MixinChunkBuilder_BuiltChunk",