Rewrite the GuiEvent.SET_SCREEN mixin to fix #35

This commit is contained in:
shedaniel
2021-03-11 21:09:22 +08:00
parent db1237448a
commit 833d6014ea
2 changed files with 32 additions and 64 deletions

View File

@@ -27,6 +27,7 @@ import me.shedaniel.architectury.platform.Platform;
import me.shedaniel.architectury.utils.Env;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screens.ChatScreen;
import net.minecraft.core.Position;
import net.minecraft.core.Vec3i;
import net.minecraft.network.chat.TranslatableComponent;
@@ -211,10 +212,6 @@ public class DebugEvents {
ClientPlayerEvent.CLIENT_PLAYER_RESPAWN.register((oldPlayer, newPlayer) -> {
SINK.accept(newPlayer.getScoreboardName() + " respawned (client)");
});
GuiEvent.SET_SCREEN.register((screen -> {
SINK.accept("Screen has been changed to " + toSimpleName(screen));
return InteractionResultHolder.pass(screen);
}));
GuiEvent.INIT_PRE.register((screen, widgets, children) -> {
SINK.accept(toSimpleName(screen) + " initializes");
return InteractionResult.PASS;
@@ -271,6 +268,14 @@ public class DebugEvents {
SINK.accept("Raw Key pressed: " + InputConstants.getKey(keyCode, scanCode).getDisplayName().getString());
return InteractionResult.PASS;
});
GuiEvent.SET_SCREEN.register(screen -> {
if (screen instanceof ChatScreen) {
return InteractionResultHolder.fail(screen);
}
SINK.accept("Screen has been changed to " + toSimpleName(screen));
return InteractionResultHolder.pass(screen);
});
}
private static String toSimpleName(Object o) {