From a42633cd4a1e255df875f01b2fbb2a0c53616e39 Mon Sep 17 00:00:00 2001 From: "James (Jamalam)" Date: Sun, 14 Apr 2024 17:33:23 +0100 Subject: [PATCH] feat: config to disable swapping items with sneak fix #40 --- CHANGELOG.md | 7 ++----- README.md | 2 -- .../java/io/github/jamalam360/utility_belt/Config.java | 1 + .../utility_belt/client/ClientNetworking.java | 10 ++++++++-- .../main/resources/assets/utility_belt/lang/en_us.json | 2 ++ gradle.properties | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b05545f..a624816 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,2 @@ -- Fix item rendering in hotbar being 1 pixel to the left -- When moving to or from the belt where there is an empty slot to place the item you are moving, you will now move to that empty slot. -- New config option to move the location of the hotbar. - -## **WARNING**: Utility Belt 2.0.0 is currently in a **BETA STATE**: backup your worlds and tread with caution! Please report any issues. +- Add an option, `useSneakSwapping`, to disable the sneak-to-swap-items behavior (#40). +- Release as non-beta version. diff --git a/README.md b/README.md index 04aa7b6..03b3c63 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,6 @@ -### **WARNING**: Utility Belt is currently in a **BETA STATE**: backup your worlds and tread with caution! Please report any issues at the link above :) - ## How to Use
diff --git a/common/src/main/java/io/github/jamalam360/utility_belt/Config.java b/common/src/main/java/io/github/jamalam360/utility_belt/Config.java index 196def6..8012ab8 100644 --- a/common/src/main/java/io/github/jamalam360/utility_belt/Config.java +++ b/common/src/main/java/io/github/jamalam360/utility_belt/Config.java @@ -3,6 +3,7 @@ public class Config { public boolean displayUtilityBeltWhenNotSelected = true; public boolean invertScrolling = false; + public boolean useSneakSwapping = true; public HotbarKeyBehaviour hotbarKeyBehaviour = HotbarKeyBehaviour.SWITCH_BELT_SLOT; public Position hotbarPosition = Position.MIDDLE_LEFT; diff --git a/common/src/main/java/io/github/jamalam360/utility_belt/client/ClientNetworking.java b/common/src/main/java/io/github/jamalam360/utility_belt/client/ClientNetworking.java index 3063a2f..3e4c4be 100644 --- a/common/src/main/java/io/github/jamalam360/utility_belt/client/ClientNetworking.java +++ b/common/src/main/java/io/github/jamalam360/utility_belt/client/ClientNetworking.java @@ -19,11 +19,17 @@ public static void init() { NetworkManager.registerReceiver(NetworkManager.Side.S2C, UtilityBelt.S2C_SET_HOTBAR_SLOT, ClientNetworking::handleSetHotbarSlot); } - public static void sendNewStateToServer(boolean inBelt, int slot, boolean swap) { + public static void sendNewStateToServer(boolean inBelt, int slot, boolean swapItems) { +// swapItems |= UtilityBelt.CONFIG.get().useSneakSwapping; + + if (swapItems && !UtilityBelt.CONFIG.get().useSneakSwapping) { + swapItems = false; + } + FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); buf.writeBoolean(inBelt); buf.writeInt(slot); - buf.writeBoolean(swap); + buf.writeBoolean(swapItems); NetworkManager.sendToServer(UtilityBelt.C2S_UPDATE_STATE, buf); } diff --git a/common/src/main/resources/assets/utility_belt/lang/en_us.json b/common/src/main/resources/assets/utility_belt/lang/en_us.json index 90d8ce1..8d5d304 100644 --- a/common/src/main/resources/assets/utility_belt/lang/en_us.json +++ b/common/src/main/resources/assets/utility_belt/lang/en_us.json @@ -7,6 +7,8 @@ "key.utility_belt.open_screen": "Open Utility Belt GUI", "config.utility_belt.invertScrolling": "Invert Scrolling in Belt Hotbar", "config.utility_belt.displayUtilityBeltWhenNotSelected": "Show Utility Belt Hotbar When Not Selected", + "config.utility_belt.useSneakSwapping": "Use Sneak to Swap Items Between Hotbars", + "config.utility_belt.useSneakSwapping.tooltip": "When enabled, you can press the sneak key while switching to the belt or hotbar to swap the items between the hotbar and the belt. Otherwise, you have to use the GUI.", "config.utility_belt.hotbarPosition": "Hotbar Position", "config.utility_belt.hotbarPosition.top_left": "Top Left", "config.utility_belt.hotbarPosition.middle_left": "Middle Left", diff --git a/gradle.properties b/gradle.properties index 350cf0a..05edb2c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false org.gradle.parallel=true -version=2.0.0-beta.2+1.20.4 +version=2.0.0+1.20.4 minecraft_version=1.20.4 branch=main group=io.github.jamalam360