From 37ff5af201cf3afd99f85ba6268192e542ce5f8c Mon Sep 17 00:00:00 2001 From: Siphalor Date: Wed, 5 Jun 2019 23:52:39 +0200 Subject: [PATCH] Version 1.2.1 * Improve the config --- gradle.properties | 2 +- .../siphalor/mousewheelie/client/Config.java | 19 ++++++++++++++----- .../mixin/MixinClientPlayNetworkHandler.java | 4 +++- .../client/mixin/MixinLivingEntity.java | 3 ++- .../client/mixin/MixinMinecraftClient.java | 11 +++++++---- .../assets/mousewheelie/lang/en_us.json | 7 ++++++- 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/gradle.properties b/gradle.properties index 33d2bcf3..7a192557 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx1G # Mod Properties mod_id = mousewheelie - mod_version = 1.2.0 + mod_version = 1.2.1 maven_group = de.siphalor archives_base_name = mousewheelie diff --git a/src/main/java/de/siphalor/mousewheelie/client/Config.java b/src/main/java/de/siphalor/mousewheelie/client/Config.java index 605cadc0..0dc7bdff 100644 --- a/src/main/java/de/siphalor/mousewheelie/client/Config.java +++ b/src/main/java/de/siphalor/mousewheelie/client/Config.java @@ -7,6 +7,7 @@ import de.siphalor.tweed.config.ConfigEnvironment; import de.siphalor.tweed.config.ConfigFile; import de.siphalor.tweed.config.TweedRegistry; +import de.siphalor.tweed.config.entry.BooleanEntry; import de.siphalor.tweed.config.entry.EnumEntry; import de.siphalor.tweed.config.entry.FloatEntry; @@ -18,24 +19,32 @@ public class Config { .setComment("Change sort modes. Existing sort modes are ALPHABET, RAW_ID and QUANTITY"); public static EnumEntry primarySort = (EnumEntry) sortCategory.register("primary-sort", new EnumEntry<>(SortMode.Predefined.RAW_ID)) .setEnvironment(ConfigEnvironment.CLIENT) - .setComment("Sets the sort mode for sorting via middle mouse click.") - ; + .setComment("Sets the sort mode for sorting via middle mouse click."); public static EnumEntry shiftSort = (EnumEntry) sortCategory.register("shift-sort", new EnumEntry<>(SortMode.Predefined.QUANTITY)) .setEnvironment(ConfigEnvironment.CLIENT) .setComment("Sets the sort mode for sorting via shift + middle mouse click."); public static EnumEntry controlSort = (EnumEntry) sortCategory.register("control-sort", new EnumEntry<>(SortMode.Predefined.ALPHABET)) .setEnvironment(ConfigEnvironment.CLIENT) .setComment("Sets the sort mode for sorting via control + middle mouse click."); - ; - public static ConfigCategory generalCategory = configFile.register("general", new ConfigCategory()); + public static ConfigCategory generalCategory = configFile.register("general", new ConfigCategory()) + .setComment("General settings"); public static FloatEntry scrollFactor = generalCategory.register("scroll-factor", new FloatEntry(-1.0F)) .setEnvironment(ConfigEnvironment.CLIENT) .setComment("Set the scroll factor for item scrolling." + System.lineSeparator() + "To invert the scrolling use negative numbers"); - public static EnumEntry toolPickMode = configFile.register("tool-pick-mode", new EnumEntry<>(ToolPickMode.HOLD_TOOL)) + public static EnumEntry toolPickMode = generalCategory.register("tool-pick-mode", new EnumEntry<>(ToolPickMode.HOLD_TOOL)) .setEnvironment(ConfigEnvironment.CLIENT); + public static ConfigCategory refillCategory = configFile.register("refill", new ConfigCategory()) + .setComment("Configure refill related stuff here."); + public static BooleanEntry eatRefill = refillCategory.register("eat", new BooleanEntry(true)) + .setEnvironment(ConfigEnvironment.CLIENT) + .setComment("Refill when eating items"); + public static BooleanEntry otherRefill = refillCategory.register("other", new BooleanEntry(true)) + .setEnvironment(ConfigEnvironment.CLIENT) + .setComment("Refill on other occasions"); + public static void initialize() { } diff --git a/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinClientPlayNetworkHandler.java b/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinClientPlayNetworkHandler.java index a0ee3216..1bf4eb44 100644 --- a/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinClientPlayNetworkHandler.java +++ b/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinClientPlayNetworkHandler.java @@ -1,6 +1,7 @@ package de.siphalor.mousewheelie.client.mixin; import de.siphalor.mousewheelie.client.ClientCore; +import de.siphalor.mousewheelie.client.Config; import de.siphalor.mousewheelie.client.InteractionManager; import de.siphalor.mousewheelie.client.util.inventory.SlotRefiller; import net.minecraft.client.MinecraftClient; @@ -47,7 +48,8 @@ public void onGuiSlotUpdate(GuiSlotUpdateS2CPacket packet, CallbackInfo callback @Inject(method = "onGuiSlotUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/container/PlayerContainer;setStackInSlot(ILnet/minecraft/item/ItemStack;)V", shift = At.Shift.AFTER)) public void onGuiSlotUpdated(GuiSlotUpdateS2CPacket packet, CallbackInfo callbackInfo) { if(mouseWheelie_scheduleRefill) { - SlotRefiller.refill(); + if(Config.otherRefill.value) + SlotRefiller.refill(); mouseWheelie_scheduleRefill = false; } } diff --git a/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinLivingEntity.java b/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinLivingEntity.java index 2282a3b3..89faf11b 100644 --- a/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinLivingEntity.java +++ b/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinLivingEntity.java @@ -1,6 +1,7 @@ package de.siphalor.mousewheelie.client.mixin; import de.siphalor.mousewheelie.client.ClientCore; +import de.siphalor.mousewheelie.client.Config; import de.siphalor.mousewheelie.client.util.inventory.SlotRefiller; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; @@ -14,7 +15,7 @@ public class MixinLivingEntity { @Inject(method = "method_6040", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;setStackInHand(Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;)V", shift = At.Shift.BEFORE)) protected void onItemUseFinish(CallbackInfo callbackInfo) { - if((Object) this instanceof PlayerEntity) { + if((Object) this instanceof PlayerEntity && Config.eatRefill.value) { PlayerInventory playerInventory = ((PlayerEntity)(Object) this).inventory; SlotRefiller.set(playerInventory, playerInventory.getMainHandStack().copy()); ClientCore.awaitFoodSlotUpdate = true; diff --git a/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinMinecraftClient.java b/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinMinecraftClient.java index e048bfd6..bd18ebb1 100644 --- a/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinMinecraftClient.java +++ b/src/main/java/de/siphalor/mousewheelie/client/mixin/MixinMinecraftClient.java @@ -1,5 +1,6 @@ package de.siphalor.mousewheelie.client.mixin; +import de.siphalor.mousewheelie.client.Config; import de.siphalor.mousewheelie.client.util.inventory.SlotRefiller; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; @@ -18,10 +19,12 @@ public class MixinMinecraftClient { @Inject(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Hand;values()[Lnet/minecraft/util/Hand;")) public void onItemUse(CallbackInfo callbackInfo) { - mouseWheelie_mainHandStack = player.getMainHandStack(); - mouseWheelie_mainHandStack = mouseWheelie_mainHandStack.isEmpty() ? null : mouseWheelie_mainHandStack.copy(); - mouseWheelie_offHandStack = player.getOffHandStack(); - mouseWheelie_offHandStack = mouseWheelie_offHandStack.isEmpty() ? null : mouseWheelie_offHandStack.copy(); + if(Config.otherRefill.value) { + mouseWheelie_mainHandStack = player.getMainHandStack(); + mouseWheelie_mainHandStack = mouseWheelie_mainHandStack.isEmpty() ? null : mouseWheelie_mainHandStack.copy(); + mouseWheelie_offHandStack = player.getOffHandStack(); + mouseWheelie_offHandStack = mouseWheelie_offHandStack.isEmpty() ? null : mouseWheelie_offHandStack.copy(); + } } @Inject(method = "doItemUse", at = @At("RETURN")) diff --git a/src/main/resources/assets/mousewheelie/lang/en_us.json b/src/main/resources/assets/mousewheelie/lang/en_us.json index a3845ba5..c8c8450b 100644 --- a/src/main/resources/assets/mousewheelie/lang/en_us.json +++ b/src/main/resources/assets/mousewheelie/lang/en_us.json @@ -6,9 +6,14 @@ "tweed.cloth.mousewheelie.general": "General", "tweed.cloth.mousewheelie.general.scroll-factor": "Scroll factor", + "tweed.cloth.mousewheelie.general.tool-pick-mode": "When to pick the correct tool", "tweed.cloth.mousewheelie.sort": "Sorting", "tweed.cloth.mousewheelie.sort.primary-sort": "Middle mouse click", "tweed.cloth.mousewheelie.sort.shift-sort": "Shift + middle mouse click", - "tweed.cloth.mousewheelie.sort.control-sort": "Control + middle mouse click" + "tweed.cloth.mousewheelie.sort.control-sort": "Control + middle mouse click", + + "tweed.cloth.mousewheelie.refill": "Refill", + "tweed.cloth.mousewheelie.refill.eat": "Refill on eating food", + "tweed.cloth.mousewheelie.refill.other": "Refill on other occasions" } \ No newline at end of file