Skip to content

Commit

Permalink
Disable Hotbar Scroll Wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
WaitingIdly committed Jun 15, 2024
1 parent 7709245 commit 153ce29
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ All changes are toggleable via config files.
* **Disable Audio Debug:** Improves loading times by removing debug code for missing sounds and subtitles
* **Disable Creeper Music Discs:** Disables creepers dropping music discs when slain by skeletons
* **Disable Fancy Missing Model:** Improves rendering performance by removing the resource location text on missing models
* **Disable Hotbar Scroll Wrapping:** Disables using the scroll wheel to change hotbar slots wrapping
* **Disable Mob Spawner Entity Render:** Disables rendering an entity inside of Mob Spawners
* **Disable Narrator:** Disables the narrator functionality entirely
* **Disable Glint Overlay on Enchantment Books:** Disables the glint overlay on enchantment books
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,11 @@ public static class MiscCategory
@Config.Comment("Disables the glint overlay on enchantment books")
public boolean utDisableEnchantmentBookGlint = false;

@Config.RequiresMcRestart
@Config.Name("Disable Hotbar Scroll Wrapping")
@Config.Comment("Disables using the scroll wheel to change hotbar slots wrapping")
public boolean utDisableHotbarScrollWrapping = false;

@Config.RequiresMcRestart
@Config.Name("Prevent Keybinds from Overflowing Screen")
@Config.Comment("Always indent keybind entries from the screen edge, preventing them from overflowing off the left side when particularly long keybind names are present")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
put("mixins.tweaks.misc.gui.potionduration.json", () -> UTConfigTweaks.MISC.utPotionDurationToggle);
put("mixins.tweaks.misc.gui.selecteditemtooltip.json", () -> UTConfigTweaks.MISC.utSelectedItemTooltipHeight != 59);
put("mixins.tweaks.misc.gui.textshadow.json", () -> UTConfigTweaks.MISC.utDisableTextShadow);
put("mixins.tweaks.misc.hotbarscroll.json", () -> UTConfigTweaks.MISC.utDisableHotbarScrollWrapping);
put("mixins.tweaks.misc.lightning.flash.json", () -> UTConfigTweaks.MISC.LIGHTNING.utLightningFlashToggle);
put("mixins.tweaks.misc.mainmenu.json", () -> UTConfigTweaks.MISC.utReturnToMainMenu);
put("mixins.tweaks.misc.music.json", () -> UTConfigTweaks.MISC.utInfiniteMusicToggle);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package mod.acgaming.universaltweaks.tweaks.misc.hotbarscroll.mixin;

import net.minecraft.entity.player.InventoryPlayer;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import mod.acgaming.universaltweaks.config.UTConfigTweaks;

// Courtesy of WaitingIdly
@Mixin(InventoryPlayer.class)
public abstract class UTInventoryPlayerMixin
{
@Shadow
public int currentItem;

@Inject(method = "changeCurrentItem", at = @At("HEAD"), cancellable = true)
private void utDefaultDifficultyMP(int direction, CallbackInfo ci)
{
if (!UTConfigTweaks.MISC.utDisableHotbarScrollWrapping) return;
int target = currentItem - (int) Math.signum(direction);
if (target < 0 || target >= InventoryPlayer.getHotbarSize())
{
ci.cancel();
}
}
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.tweaks.misc.hotbarscroll.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.misc.hotbarscroll.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"client": ["UTInventoryPlayerMixin"]
}

0 comments on commit 153ce29

Please sign in to comment.