generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix #27
- Loading branch information
Showing
7 changed files
with
57 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/hamarb123/macos_input_fixes/mixin/gui/OptionListWidgetMixin8.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.hamarb123.macos_input_fixes.mixin.gui; | ||
|
||
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.ModifyVariable; | ||
import com.hamarb123.macos_input_fixes.ModOptions; | ||
import net.minecraft.client.gui.screen.option.GameOptionsScreen; | ||
import net.minecraft.client.gui.screen.option.MouseOptionsScreen; | ||
import net.minecraft.client.gui.widget.OptionListWidget; | ||
import net.minecraft.client.option.SimpleOption; | ||
|
||
@Mixin(OptionListWidget.class) | ||
public class OptionListWidgetMixin8 | ||
{ | ||
@Shadow(remap = false, aliases = {"field_49483"}) | ||
private GameOptionsScreen optionsScreen; | ||
|
||
//this is where we add additional menu options | ||
@ModifyVariable(method = "addAll([Lnet/minecraft/client/option/SimpleOption;)V", at = @At("HEAD"), ordinal = 0) | ||
private SimpleOption<?>[] modifyAddAllParameter1(SimpleOption<?>[] options) | ||
{ | ||
//check if it's a MouseOptionsScreen, otherwise we don't want to modify | ||
if (!(optionsScreen instanceof MouseOptionsScreen)) return options; | ||
|
||
//get the mod options so we can add them to the game options | ||
Object[] modOptions = ModOptions.getModOptions(); | ||
if (modOptions == null) return options; | ||
|
||
//combine the game options and mod options | ||
SimpleOption<?>[] newOptions = new SimpleOption<?>[options.length + modOptions.length]; | ||
for (int i = 0; i < options.length; i++) newOptions[i] = options[i]; | ||
for (int i = 0; i < modOptions.length; i++) newOptions[options.length + i] = (SimpleOption<?>)modOptions[i]; | ||
return newOptions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters