Skip to content

Commit

Permalink
Version 1.2.1
Browse files Browse the repository at this point in the history
* Improve the config
  • Loading branch information
Siphalor committed Jun 5, 2019
1 parent 98cb78e commit 37ff5af
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 14 additions & 5 deletions src/main/java/de/siphalor/mousewheelie/client/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -18,24 +19,32 @@ public class Config {
.setComment("Change sort modes. Existing sort modes are ALPHABET, RAW_ID and QUANTITY");
public static EnumEntry<SortMode.Predefined> primarySort = (EnumEntry<SortMode.Predefined>) 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<SortMode.Predefined> shiftSort = (EnumEntry<SortMode.Predefined>) 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<SortMode.Predefined> controlSort = (EnumEntry<SortMode.Predefined>) 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> toolPickMode = configFile.register("tool-pick-mode", new EnumEntry<>(ToolPickMode.HOLD_TOOL))
public static EnumEntry<ToolPickMode> 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() {

}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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"))
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/assets/mousewheelie/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 37ff5af

Please sign in to comment.