Skip to content

Commit

Permalink
feat: inject code into GuiScreen to set mc variable on init
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Dec 17, 2023
1 parent 73fe284 commit 317ca22
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
package gg.skytils.skytilsmod.mixins.transformers.gui;

import gg.skytils.skytilsmod.mixins.hooks.gui.GuiScreenHookKt;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.util.IChatComponent;
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;
Expand All @@ -32,6 +34,13 @@
@Mixin(GuiScreen.class)
public abstract class MixinGuiScreen extends Gui implements GuiYesNoCallback {

@Shadow public Minecraft mc;

@Inject(method = "<init>", at = @At("RETURN"))
private void onInit(CallbackInfo ci) {
this.mc = Minecraft.getMinecraft();
}

@Inject(method = "sendChatMessage(Ljava/lang/String;Z)V", at = @At("HEAD"), cancellable = true)
private void onSendChatMessage(String message, boolean addToChat, CallbackInfo ci) {
GuiScreenHookKt.onSendChatMessage(message, addToChat, ci);
Expand Down

0 comments on commit 317ca22

Please sign in to comment.