generated from KessokuTeaTime/Example-Mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
133 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.krlite.it_follows; | ||
|
||
import net.fabricmc.api.ModInitializer; | ||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.minecraft.client.gui.widget.CyclingButtonWidget; | ||
import net.minecraft.client.gui.widget.PressableWidget; | ||
import net.minecraft.util.ActionResult; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.joml.Vector2i; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class ItFollows implements ModInitializer { | ||
public static final String NAME = "It Follows!", ID = "it-follows"; | ||
public static final Logger LOGGER = LoggerFactory.getLogger(ID); | ||
|
||
@Nullable | ||
private static PressableWidget GUI_SCALE_WIDGET = null; | ||
@Nullable | ||
private static Vector2i BUTTON_POS = null; | ||
|
||
@Override | ||
public void onInitialize() { | ||
} | ||
|
||
public static void guiScaleWidget(PressableWidget widget) { | ||
GUI_SCALE_WIDGET = widget; | ||
} | ||
|
||
public static @Nullable Vector2i buttonPos() { | ||
return BUTTON_POS; | ||
} | ||
|
||
public static void buttonPos(PressableWidget widget, int x, int y) { | ||
if (widget.equals(GUI_SCALE_WIDGET)) { | ||
BUTTON_POS = new Vector2i(x, y); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/net/krlite/it_follows/mixin/CyclingButtonWidgetMixin.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,22 @@ | ||
package net.krlite.it_follows.mixin; | ||
|
||
import net.krlite.it_follows.ItFollows; | ||
import net.minecraft.client.gui.widget.CyclingButtonWidget; | ||
import net.minecraft.client.gui.widget.PressableWidget; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(CyclingButtonWidget.class) | ||
public abstract class CyclingButtonWidgetMixin extends PressableWidget { | ||
public CyclingButtonWidgetMixin(int i, int j, int k, int l, Text text) { | ||
super(i, j, k, l, text); | ||
} | ||
|
||
@Inject(method = "cycle", at = @At("HEAD")) | ||
private void cycleHead(int amount, CallbackInfo ci) { | ||
ItFollows.buttonPos(this, getX(), getY()); | ||
} | ||
} |
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,25 @@ | ||
package net.krlite.it_follows.mixin; | ||
|
||
import net.krlite.it_follows.ItFollows; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.Mouse; | ||
import org.joml.Vector2i; | ||
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; | ||
|
||
@Mixin(Mouse.class) | ||
public abstract class MouseMixin { | ||
@Shadow protected abstract void onCursorPos(long window, double x, double y); | ||
|
||
@Inject(method = "onResolutionChanged", at = @At("RETURN")) | ||
private void onResolutionChanged(CallbackInfo ci) { | ||
Vector2i pos = ItFollows.buttonPos(); | ||
if (pos != null) { | ||
onCursorPos(MinecraftClient.getInstance().getWindow().getHandle(), pos.x(), pos.y()); | ||
System.out.println(pos.x() + ", " + pos.y()); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/net/krlite/it_follows/mixin/VideoOptionsScreenMixin.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,26 @@ | ||
package net.krlite.it_follows.mixin; | ||
|
||
import net.krlite.it_follows.ItFollows; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.screen.option.GameOptionsScreen; | ||
import net.minecraft.client.gui.screen.option.VideoOptionsScreen; | ||
import net.minecraft.client.gui.widget.CyclingButtonWidget; | ||
import net.minecraft.client.gui.widget.OptionListWidget; | ||
import net.minecraft.client.option.GameOptions; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(VideoOptionsScreen.class) | ||
public class VideoOptionsScreenMixin extends GameOptionsScreen { | ||
public VideoOptionsScreenMixin(Screen parent, GameOptions gameOptions, Text title) { | ||
super(parent, gameOptions, title); | ||
} | ||
|
||
@Inject(method = "init", at = @At("TAIL")) | ||
private void init(CallbackInfo ci) { | ||
ItFollows.guiScaleWidget((CyclingButtonWidget<?>) (((OptionListWidget) children().get(0)).children().get(6)).children().get(0)); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
accessWidener v1 named | ||
accessible method net/minecraft/client/gui/widget/OptionListWidget$WidgetEntry children ()Ljava/util/List; |
5 changes: 4 additions & 1 deletion
5
src/main/resources/modid.mixins.json → src/main/resources/it_follows.mixins.json
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