Skip to content

Commit

Permalink
1.7 part 1
Browse files Browse the repository at this point in the history
- Fix #27
  • Loading branch information
hamarb123 committed May 23, 2024
1 parent 11f9ee7 commit 6f69691
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 8 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,20 @@ If you make changes, you should test everything works properly on the following
- 1.19
- 1.19.3
- 1.20
- 1.21

## Mixin Naming Scheme

Some mixins are in a folder called `gui`, these mixins are to do with the option menu interface, or only used by other option menu interface code. Some mixins have a number at the end of their name, these mixins are conditionally loaded based on whether certain classes are available at runtime. The numbering is currently as follows (note some of the classes may have different names in different intermediary mappings, consult the latest applicable version if you can't find the class):
1. The `SimpleOption` class is available (1.19+)
2. The `Option` class is available (1.14-1.18)
2. The `Option` class is available (1.14-1.18.x)
3. The `CyclingButtonWidget` class is available (1.17+)
4. Both the `Option` and `CyclingButtonWidget` classes are available (1.17-1.18)
4. Both the `Option` and `CyclingButtonWidget` classes are available (1.17-1.18.x)
5. The `GameOptionsScreen.getHoveredButtonTooltip(ButtonListWidget, int, int)` function exists (1.16.2-1.19.2)
6. The `GameOptionsScreen.getHoveredButtonTooltip(ButtonListWidget, int, int)` function doesn't exist, the `Screen.renderTooltip(MatrixStack, List, int, int)` function exists, and the `Option` class exists (1.16-1.16.1)
7. Either 5 or 6 (1.16-1.19.2)
8. 1 and doesn't have `MouseOptionsScreen.init()` (1.21+)
9. 1 and has `MouseOptionsScreen.init()` (1.19-1.20.x)

## License

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.14.22

# Mod Properties
mod_version = 1.6
mod_version = 1.7
maven_group = com.hamarb123.macos_input_fixes
archives_base_name = macos-input-fixes
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public static Class<?> SimpleOption_Callbacks()
/**
* <p>Intemediary name: {@code net.minecraft.class_7172$class_7277}</p>
* <p>Mapped name: {@code net.minecraft.client.option.SimpleOption$TooltipFactoryGetter}</p>
* <p>Versions: 1.19+</p>
* <p>Versions: 1.19-1.19.2</p>
*/
public static Class<?> SimpleOption_TooltipFactory()
{
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/com/hamarb123/macos_input_fixes/MixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public List<String> getMixins()
boolean hasScreen_renderTooltip = isMethodPresent(resolver.mapClassName("intermediary", "net.minecraft.class_437"),
resolver.mapMethodName("intermediary", "net.minecraft.class_437", "method_25417", "(Lnet/minecraft/class_4587;Ljava/util/List;II)V"),
"(L" + resolver.mapClassName("intermediary", "net.minecraft.class_4587").replace(".", "/") + ";Ljava/util/List;II)V");
boolean hasMouseOptionsScreen_init = isMethodPresent(resolver.mapClassName("intermediary", "net.minecraft.class_4288"),
resolver.mapMethodName("intermediary", "net.minecraft.class_4288", "method_25426", "()V"),
"()V");
if (hasOptionClass)
{
li.add("gui.MouseOptionsScreenMixin2");
Expand All @@ -59,9 +62,16 @@ public List<String> getMixins()
}
else
{
li.add("gui.MouseOptionsScreenMixin1");
li.add("gui.OptionListWidgetMixin1");
li.add("gui.SimpleOptionMixin1");
if (hasMouseOptionsScreen_init)
{
li.add("gui.MouseOptionsScreenMixin9");
li.add("gui.OptionListWidgetMixin9");
}
else
{
li.add("gui.OptionListWidgetMixin8");
}
}
if (hasCyclingButtonWidgetClass)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.client.gui.screen.option.MouseOptionsScreen;

@Mixin(MouseOptionsScreen.class)
public class MouseOptionsScreenMixin1
public class MouseOptionsScreenMixin9
{
//sets the modifyAddAllParameter() flag, which is checked and reset in ButtonListWidgetMixin1
@Inject(method = "init()V", at = @At("HEAD"))
Expand Down
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.minecraft.client.option.SimpleOption;

@Mixin(OptionListWidget.class)
public class OptionListWidgetMixin1
public class OptionListWidgetMixin9
{
//this is where we add additional menu options
@ModifyVariable(method = "addAll([Lnet/minecraft/client/option/SimpleOption;)V", at = @At("HEAD"), ordinal = 0)
Expand Down

0 comments on commit 6f69691

Please sign in to comment.