This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[skip ci] Merge pull request #43 from mysticdrew/chat-mixin-fix
fix mod conflicts with chat mixins
- Loading branch information
Showing
3 changed files
with
39 additions
and
26 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
28 changes: 17 additions & 11 deletions
28
src/main/java/io/github/darkkronicle/advancedchatcore/mixin/MixinSleepingChatScreen.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 |
---|---|---|
@@ -1,30 +1,36 @@ | ||
/* | ||
* Copyright (C) 2021 DarkKronicle | ||
* Copyright (C) 2021-2022 DarkKronicle | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
package io.github.darkkronicle.advancedchatcore.mixin; | ||
|
||
import fi.dy.masa.malilib.gui.GuiBase; | ||
import io.github.darkkronicle.advancedchatcore.chat.AdvancedSleepingChatScreen; | ||
import io.github.darkkronicle.advancedchatcore.chat.AdvancedChatScreen; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.gui.screen.ChatScreen; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.screen.SleepingChatScreen; | ||
import org.jetbrains.annotations.Nullable; | ||
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; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@Mixin(SleepingChatScreen.class) | ||
public class MixinSleepingChatScreen { | ||
public class MixinSleepingChatScreen extends ChatScreen { | ||
|
||
@Inject(method = "init", at = @At("HEAD"), cancellable = true) | ||
public void sleepInit(CallbackInfo ci) { | ||
// Open the Advanced sleeping screen | ||
GuiBase.openGui(new AdvancedSleepingChatScreen()); | ||
ci.cancel(); | ||
public MixinSleepingChatScreen() { | ||
super(""); | ||
} | ||
|
||
@ModifyArg(method = "closeChatIfEmpty", | ||
at = @At(value = "INVOKE", | ||
target = "Lnet/minecraft/client/MinecraftClient;setScreen(Lnet/minecraft/client/gui/screen/Screen;)V", ordinal = 1)) | ||
public Screen openSleepingChatScreen(@Nullable Screen screen) { | ||
|
||
return new AdvancedChatScreen(this.chatField.getText()); | ||
} | ||
} |