From 99d4a88df013c03aa3e82bc75ec3e6ece65b9df9 Mon Sep 17 00:00:00 2001 From: nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> Date: Sun, 3 Jul 2022 12:35:21 +0100 Subject: changes to ESC behavior --- .../internal/mixin/GuiIngameForgeMixin.java | 18 ----- .../oneconfig/internal/mixin/MinecraftMixin.java | 94 ---------------------- .../internal/mixin/NetHandlerPlayClientMixin.java | 36 --------- .../internal/mixin/NetworkManagerMixin.java | 23 ------ .../internal/mixin/OptifineConfigMixin.java | 21 ----- .../internal/mixin/ShaderGroupAccessor.java | 14 ---- .../oneconfig/internal/mixin/VigilantMixin.java | 8 -- .../oneconfig/internal/mixin/WorldClientMixin.java | 21 ----- 8 files changed, 235 deletions(-) delete mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java delete mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java delete mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java delete mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java delete mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/OptifineConfigMixin.java delete mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ShaderGroupAccessor.java delete mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java delete mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java (limited to 'versions/1.12.2-forge') diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java deleted file mode 100644 index 775e055..0000000 --- a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java +++ /dev/null @@ -1,18 +0,0 @@ -package cc.polyfrost.oneconfig.internal.mixin; - -import cc.polyfrost.oneconfig.events.EventManager; -import cc.polyfrost.oneconfig.events.event.HudRenderEvent; -import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; -import net.minecraftforge.client.GuiIngameForge; -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(value = GuiIngameForge.class, remap = false) -public class GuiIngameForgeMixin { - @Inject(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;post(Lnet/minecraftforge/client/event/RenderGameOverlayEvent$ElementType;)V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onRenderGameOverlay(float partialTicks, CallbackInfo ci) { - EventManager.INSTANCE.post(new HudRenderEvent(new UMatrixStack(), partialTicks)); - } -} \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java deleted file mode 100644 index 9492238..0000000 --- a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java +++ /dev/null @@ -1,94 +0,0 @@ -package cc.polyfrost.oneconfig.internal.mixin; - -import cc.polyfrost.oneconfig.events.EventManager; -import cc.polyfrost.oneconfig.events.event.*; -import cc.polyfrost.oneconfig.internal.OneConfig; -import net.minecraft.client.Minecraft; -import net.minecraft.util.Timer; -import net.minecraftforge.client.event.GuiOpenEvent; -import net.minecraftforge.fml.common.eventhandler.Event; -import org.spongepowered.asm.mixin.Final; -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.ModifyArg; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(Minecraft.class) -public class MinecraftMixin { - @Final - @Shadow - private Timer timer; - - @Inject(method = "shutdownMinecraftApplet", at = @At("HEAD")) - private void onShutdown(CallbackInfo ci) { - EventManager.INSTANCE.post(new PreShutdownEvent()); - } - - @Inject(method = "init", at = @At("HEAD")) - private void onStart(CallbackInfo ci) { - EventManager.INSTANCE.post(new StartEvent()); - Runtime.getRuntime().addShutdownHook(new Thread(() -> EventManager.INSTANCE.post(new ShutdownEvent()))); - } - - @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;beginMinecraftLoading(Lnet/minecraft/client/Minecraft;Ljava/util/List;Lnet/minecraft/client/resources/IReloadableResourceManager;Lnet/minecraft/client/resources/data/MetadataSerializer;)V", remap = false), remap = true) - private void onPreLaunch(CallbackInfo ci) { - OneConfig.preLaunch(); - } - - @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;onInitializationComplete()V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onInit(CallbackInfo ci) { - EventManager.INSTANCE.post(new InitializationEvent()); - OneConfig.init(); - } - - @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onRenderTickStart(F)V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onRenderTickStart(CallbackInfo ci) { - EventManager.INSTANCE.post(new RenderEvent(Stage.START, timer.renderPartialTicks)); - } - - @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onRenderTickEnd(F)V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onRenderTickEnd(CallbackInfo ci) { - EventManager.INSTANCE.post(new RenderEvent(Stage.END, timer.renderPartialTicks)); - } - - @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onPreClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onClientTickStart(CallbackInfo ci) { - EventManager.INSTANCE.post(new TickEvent(Stage.START)); - } - - @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onPostClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onClientTickEnd(CallbackInfo ci) { - EventManager.INSTANCE.post(new TickEvent(Stage.END)); - } - - @ModifyArg(method = "displayGuiScreen", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/eventhandler/EventBus;post(Lnet/minecraftforge/fml/common/eventhandler/Event;)Z", remap = false), remap = true) - private Event onGuiOpenEvent(Event a) { - if (a instanceof GuiOpenEvent) { - GuiOpenEvent forgeEvent = (GuiOpenEvent) a; - ScreenOpenEvent event = new ScreenOpenEvent(forgeEvent.getGui()); - EventManager.INSTANCE.post(event); - if (event.isCancelled) { - forgeEvent.setCanceled(true); - } - return forgeEvent; - } - return a; - } - - @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Timer;updateTimer()V", shift = At.Shift.AFTER)) - private void onDeltaTickTimerUpdate(CallbackInfo ci) { - EventManager.INSTANCE.post(new TimerUpdateEvent(timer, true)); - } - - @Inject(method = "runTickKeyboard", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;fireKeyInput()V")) - private void onKeyEvent(CallbackInfo ci) { - EventManager.INSTANCE.post(new KeyInputEvent()); - } - - @Inject(method = "runTickMouse", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;fireMouseInput()V")) - private void onMouseEvent(CallbackInfo ci) { - EventManager.INSTANCE.post(new MouseInputEvent()); - } -} \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java deleted file mode 100644 index 5b54e8e..0000000 --- a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package cc.polyfrost.oneconfig.internal.mixin; - -import cc.polyfrost.oneconfig.events.EventManager; -import cc.polyfrost.oneconfig.events.event.ChatReceiveEvent; -import cc.polyfrost.oneconfig.events.event.SendPacketEvent; -import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.network.Packet; -import net.minecraft.network.play.server.SPacketChat; -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(value = NetHandlerPlayClient.class, priority = Integer.MAX_VALUE) -public class NetHandlerPlayClientMixin { - - @Inject(method = "sendPacket", at = @At("HEAD"), cancellable = true) - private void onSendPacket(Packet p_147297_1_, CallbackInfo ci) { - SendPacketEvent event = new SendPacketEvent(p_147297_1_); - EventManager.INSTANCE.post(event); - if (event.isCancelled) { - ci.cancel(); - } - } - - @Inject(method = "handleChat", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/event/ForgeEventFactory;onClientChat(Lnet/minecraft/util/text/ChatType;Lnet/minecraft/util/text/ITextComponent;)Lnet/minecraft/util/text/ITextComponent;", remap = false), cancellable = true, remap = true) - private void onClientChat(SPacketChat packetIn, CallbackInfo ci) { - if (packetIn.getType().getId() == 0) { - ChatReceiveEvent event = new ChatReceiveEvent(packetIn.getChatComponent()); - EventManager.INSTANCE.post(event); - if (event.isCancelled) { - ci.cancel(); - } - } - } -} \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java deleted file mode 100644 index 7ddaf80..0000000 --- a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java +++ /dev/null @@ -1,23 +0,0 @@ -package cc.polyfrost.oneconfig.internal.mixin; - -import cc.polyfrost.oneconfig.events.EventManager; -import cc.polyfrost.oneconfig.events.event.ReceivePacketEvent; -import io.netty.channel.ChannelHandlerContext; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.Packet; -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(value = NetworkManager.class, priority = Integer.MAX_VALUE) -public class NetworkManagerMixin { - @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) - private void onReceivePacket(ChannelHandlerContext p_channelRead0_1_, Packet p_channelRead0_2_, CallbackInfo ci) { - ReceivePacketEvent event = new ReceivePacketEvent(p_channelRead0_2_); - EventManager.INSTANCE.post(event); - if (event.isCancelled) { - ci.cancel(); - } - } -} \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/OptifineConfigMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/OptifineConfigMixin.java deleted file mode 100644 index eb6fc03..0000000 --- a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/OptifineConfigMixin.java +++ /dev/null @@ -1,21 +0,0 @@ -package cc.polyfrost.oneconfig.internal.mixin; - -import cc.polyfrost.oneconfig.internal.plugin.hooks.OptifineConfigHook; -import org.spongepowered.asm.mixin.Dynamic; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Pseudo -@Mixin(targets = "Config", remap = false) -public class OptifineConfigMixin { - @Dynamic("OptiFine") - @Inject(method = "isFastRender", at = @At("HEAD"), cancellable = true) - private static void cancelFastRender(CallbackInfoReturnable cir) { - if (OptifineConfigHook.shouldNotApplyFastRender()) { - cir.setReturnValue(false); - } - } -} \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ShaderGroupAccessor.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ShaderGroupAccessor.java deleted file mode 100644 index 2ec0024..0000000 --- a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ShaderGroupAccessor.java +++ /dev/null @@ -1,14 +0,0 @@ -package cc.polyfrost.oneconfig.internal.mixin; - -import net.minecraft.client.shader.Shader; -import net.minecraft.client.shader.ShaderGroup; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.util.List; - -@Mixin(ShaderGroup.class) -public interface ShaderGroupAccessor { - @Accessor("listShaders") - List getListShaders(); -} \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java deleted file mode 100644 index 04e3fe9..0000000 --- a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java +++ /dev/null @@ -1,8 +0,0 @@ -package cc.polyfrost.oneconfig.internal.mixin; - -import gg.essential.vigilance.Vigilant; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(Vigilant.class) -public class VigilantMixin { -} \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java deleted file mode 100644 index 42caec3..0000000 --- a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java +++ /dev/null @@ -1,21 +0,0 @@ -package cc.polyfrost.oneconfig.internal.mixin; - -import cc.polyfrost.oneconfig.events.EventManager; -import cc.polyfrost.oneconfig.events.event.WorldLoadEvent; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.profiler.Profiler; -import net.minecraft.world.EnumDifficulty; -import net.minecraft.world.WorldSettings; -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(WorldClient.class) -public class WorldClientMixin { - @Inject(method = "", at = @At("RETURN")) - private void onWorldLoad(NetHandlerPlayClient p_i45063_1_, WorldSettings p_i45063_2_, int p_i45063_3_, EnumDifficulty p_i45063_4_, Profiler p_i45063_5_, CallbackInfo ci) { - EventManager.INSTANCE.post(new WorldLoadEvent()); - } -} \ No newline at end of file -- cgit From fecb67e07ded0d20b12d3bdb48fea3e2e50b7f88 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Sun, 3 Jul 2022 21:11:39 +0700 Subject: little trolling --- versions/1.12.2-1.16.2.txt | 16 ++ .../internal/mixin/GuiIngameForgeMixin.java | 18 +++ .../oneconfig/internal/mixin/MinecraftMixin.java | 94 ++++++++++++ .../internal/mixin/NetHandlerPlayClientMixin.java | 25 ++++ .../internal/mixin/NetworkManagerMixin.java | 42 ++++++ .../oneconfig/internal/mixin/WorldClientMixin.java | 21 +++ .../internal/mixin/ClientModLoaderMixin.java | 23 +++ .../internal/mixin/GuiIngameForgeMixin.java | 19 +++ .../internal/mixin/KeyboardListenerMixin.java | 17 +++ .../oneconfig/internal/mixin/MinecraftMixin.java | 66 ++++++++ .../oneconfig/internal/mixin/MouseHelperMixin.java | 17 +++ .../internal/mixin/NetHandlerPlayClientMixin.java | 25 ++++ .../internal/mixin/NetworkManagerMixin.java | 42 ++++++ .../oneconfig/internal/mixin/TimeTrackerMixin.java | 22 +++ .../oneconfig/internal/mixin/WorldClientMixin.java | 25 ++++ versions/1.8.9-1.16.2.txt | 19 --- versions/root.gradle.kts | 5 +- .../cc/polyfrost/oneconfig/internal/OneConfig.java | 1 - .../internal/mixin/GuiIngameForgeMixin.java | 32 ++-- .../oneconfig/internal/mixin/MinecraftMixin.java | 166 ++++++++++----------- .../internal/mixin/NetHandlerPlayClientMixin.java | 57 +++---- .../internal/mixin/NetworkManagerMixin.java | 60 +++++--- .../internal/mixin/OptifineConfigMixin.java | 40 +++-- .../oneconfig/internal/mixin/VigilantMixin.java | 14 +- .../oneconfig/internal/mixin/WorldClientMixin.java | 38 ++--- 25 files changed, 681 insertions(+), 223 deletions(-) create mode 100644 versions/1.12.2-1.16.2.txt create mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java create mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java create mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java create mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java create mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ClientModLoaderMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/KeyboardListenerMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseHelperMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/TimeTrackerMixin.java create mode 100644 versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java delete mode 100644 versions/1.8.9-1.16.2.txt (limited to 'versions/1.12.2-forge') diff --git a/versions/1.12.2-1.16.2.txt b/versions/1.12.2-1.16.2.txt new file mode 100644 index 0000000..5171175 --- /dev/null +++ b/versions/1.12.2-1.16.2.txt @@ -0,0 +1,16 @@ +net.minecraft.util.text.ITextComponent getUnformattedText() getUnformattedComponentText() +net.minecraft.network.Packet net.minecraft.network.IPacket +net.minecraft.client.gui.GuiScreen net.minecraft.client.gui.screen.Screen +net.minecraft.client.gui.GuiChat net.minecraft.client.gui.screen.ChatScreen +net.minecraft.client.Minecraft getMinecraft() getInstance() +net.minecraft.client.Minecraft isCallingFromMinecraftThread() isOnExecutionThread() +net.minecraft.client.entity.EntityPlayerSP getClientBrand() getServerBrand() +net.minecraft.client.entity.EntityPlayerSP net.minecraft.client.entity.player.ClientPlayerEntity +net.minecraft.launchwrapper.IClassTransformer transform() transformClassBytes() +net.minecraft.launchwrapper.IClassTransformer org.spongepowered.asm.service.ILegacyClassTransformer +net.minecraft.client.Minecraft entityRenderer gameRenderer +net.minecraftforge.fml.common.event.FMLInitializationEvent net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent +net.minecraft.client.shader.ShaderUniform net.minecraft.client.shader.ShaderDefault +net.minecraftforge.fml.common.Loader instance() get() +net.minecraftforge.fml.common.Loader net.minecraftforge.fml.ModLoadingContext +net.minecraftforge.fml.common.ModContainer net.minecraftforge.fml.ModContainer \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java new file mode 100644 index 0000000..775e055 --- /dev/null +++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java @@ -0,0 +1,18 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.HudRenderEvent; +import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; +import net.minecraftforge.client.GuiIngameForge; +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(value = GuiIngameForge.class, remap = false) +public class GuiIngameForgeMixin { + @Inject(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;post(Lnet/minecraftforge/client/event/RenderGameOverlayEvent$ElementType;)V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onRenderGameOverlay(float partialTicks, CallbackInfo ci) { + EventManager.INSTANCE.post(new HudRenderEvent(new UMatrixStack(), partialTicks)); + } +} \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java new file mode 100644 index 0000000..9492238 --- /dev/null +++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java @@ -0,0 +1,94 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.*; +import cc.polyfrost.oneconfig.internal.OneConfig; +import net.minecraft.client.Minecraft; +import net.minecraft.util.Timer; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.fml.common.eventhandler.Event; +import org.spongepowered.asm.mixin.Final; +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.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Minecraft.class) +public class MinecraftMixin { + @Final + @Shadow + private Timer timer; + + @Inject(method = "shutdownMinecraftApplet", at = @At("HEAD")) + private void onShutdown(CallbackInfo ci) { + EventManager.INSTANCE.post(new PreShutdownEvent()); + } + + @Inject(method = "init", at = @At("HEAD")) + private void onStart(CallbackInfo ci) { + EventManager.INSTANCE.post(new StartEvent()); + Runtime.getRuntime().addShutdownHook(new Thread(() -> EventManager.INSTANCE.post(new ShutdownEvent()))); + } + + @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;beginMinecraftLoading(Lnet/minecraft/client/Minecraft;Ljava/util/List;Lnet/minecraft/client/resources/IReloadableResourceManager;Lnet/minecraft/client/resources/data/MetadataSerializer;)V", remap = false), remap = true) + private void onPreLaunch(CallbackInfo ci) { + OneConfig.preLaunch(); + } + + @Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;onInitializationComplete()V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onInit(CallbackInfo ci) { + EventManager.INSTANCE.post(new InitializationEvent()); + OneConfig.init(); + } + + @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onRenderTickStart(F)V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onRenderTickStart(CallbackInfo ci) { + EventManager.INSTANCE.post(new RenderEvent(Stage.START, timer.renderPartialTicks)); + } + + @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onRenderTickEnd(F)V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onRenderTickEnd(CallbackInfo ci) { + EventManager.INSTANCE.post(new RenderEvent(Stage.END, timer.renderPartialTicks)); + } + + @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onPreClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onClientTickStart(CallbackInfo ci) { + EventManager.INSTANCE.post(new TickEvent(Stage.START)); + } + + @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onPostClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onClientTickEnd(CallbackInfo ci) { + EventManager.INSTANCE.post(new TickEvent(Stage.END)); + } + + @ModifyArg(method = "displayGuiScreen", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/eventhandler/EventBus;post(Lnet/minecraftforge/fml/common/eventhandler/Event;)Z", remap = false), remap = true) + private Event onGuiOpenEvent(Event a) { + if (a instanceof GuiOpenEvent) { + GuiOpenEvent forgeEvent = (GuiOpenEvent) a; + ScreenOpenEvent event = new ScreenOpenEvent(forgeEvent.getGui()); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + forgeEvent.setCanceled(true); + } + return forgeEvent; + } + return a; + } + + @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Timer;updateTimer()V", shift = At.Shift.AFTER)) + private void onDeltaTickTimerUpdate(CallbackInfo ci) { + EventManager.INSTANCE.post(new TimerUpdateEvent(timer, true)); + } + + @Inject(method = "runTickKeyboard", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;fireKeyInput()V")) + private void onKeyEvent(CallbackInfo ci) { + EventManager.INSTANCE.post(new KeyInputEvent()); + } + + @Inject(method = "runTickMouse", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;fireMouseInput()V")) + private void onMouseEvent(CallbackInfo ci) { + EventManager.INSTANCE.post(new MouseInputEvent()); + } +} \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java new file mode 100644 index 0000000..d2a68ff --- /dev/null +++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java @@ -0,0 +1,25 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.ChatReceiveEvent; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.play.server.SPacketChat; +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(value = NetHandlerPlayClient.class, priority = Integer.MAX_VALUE) +public class NetHandlerPlayClientMixin { + + @Inject(method = "handleChat", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/event/ForgeEventFactory;onClientChat(Lnet/minecraft/util/text/ChatType;Lnet/minecraft/util/text/ITextComponent;)Lnet/minecraft/util/text/ITextComponent;", remap = false), cancellable = true, remap = true) + private void onClientChat(SPacketChat packetIn, CallbackInfo ci) { + if (packetIn.getType().getId() == 0) { + ChatReceiveEvent event = new ChatReceiveEvent(packetIn.getChatComponent()); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + ci.cancel(); + } + } + } +} \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java new file mode 100644 index 0000000..023fdaa --- /dev/null +++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java @@ -0,0 +1,42 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.ReceivePacketEvent; +import cc.polyfrost.oneconfig.events.event.SendPacketEvent; +import io.netty.channel.ChannelHandlerContext; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +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(value = NetworkManager.class, priority = Integer.MAX_VALUE) +public class NetworkManagerMixin { + + @Inject(method = "sendPacket(Lnet/minecraft/network/Packet;Lio/netty/util/concurrent/GenericFutureListener;[Lio/netty/util/concurrent/GenericFutureListener;)V", at = @At("HEAD"), cancellable = true) + private void onSendPacket(Packet packetIn, GenericFutureListener> listener, GenericFutureListener>[] listeners, CallbackInfo ci) { + onSendPacket(packetIn, ci); + } + + @Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) + private void onSendPacket(Packet packetIn, CallbackInfo ci) { + SendPacketEvent event = new SendPacketEvent(packetIn); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + ci.cancel(); + } + } + + + @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) + private void onReceivePacket(ChannelHandlerContext p_channelRead0_1_, Packet p_channelRead0_2_, CallbackInfo ci) { + ReceivePacketEvent event = new ReceivePacketEvent(p_channelRead0_2_); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + ci.cancel(); + } + } +} \ No newline at end of file diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java new file mode 100644 index 0000000..42caec3 --- /dev/null +++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java @@ -0,0 +1,21 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.WorldLoadEvent; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.profiler.Profiler; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.WorldSettings; +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(WorldClient.class) +public class WorldClientMixin { + @Inject(method = "", at = @At("RETURN")) + private void onWorldLoad(NetHandlerPlayClient p_i45063_1_, WorldSettings p_i45063_2_, int p_i45063_3_, EnumDifficulty p_i45063_4_, Profiler p_i45063_5_, CallbackInfo ci) { + EventManager.INSTANCE.post(new WorldLoadEvent()); + } +} \ No newline at end of file diff --git a/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ClientModLoaderMixin.java b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ClientModLoaderMixin.java new file mode 100644 index 0000000..2bfbaef --- /dev/null +++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ClientModLoaderMixin.java @@ -0,0 +1,23 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.InitializationEvent; +import net.minecraftforge.fml.client.ClientModLoader; +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(value = ClientModLoader.class, remap = false) +public class ClientModLoaderMixin { //todo + @Inject(method = "begin", at = @At("HEAD")) + private static void onBegin(CallbackInfo ci) { + OneConfig.preLaunch(); + } + + @Inject(method = "finishModLoading", at = @At("HEAD")) + private static void onFinishModLoading(CallbackInfo ci) { + EventManager.INSTANCE.post(new InitializationEvent()); + OneConfig.init(); + } +} diff --git a/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java new file mode 100644 index 0000000..f4ea663 --- /dev/null +++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java @@ -0,0 +1,19 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.HudRenderEvent; +import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraftforge.client.gui.ForgeIngameGui; +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(value = ForgeIngameGui.class, remap = false) +public class GuiIngameForgeMixin { + @Inject(method = "renderIngameGui", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/gui/ForgeIngameGui;post(Lnet/minecraftforge/client/event/RenderGameOverlayEvent$ElementType;Lcom/mojang/blaze3d/matrix/MatrixStack;)V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onRenderGameOverlay(MatrixStack matrixStack, float partialTicks, CallbackInfo ci) { + EventManager.INSTANCE.post(new HudRenderEvent(new UMatrixStack(), partialTicks)); + } +} \ No newline at end of file diff --git a/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/KeyboardListenerMixin.java b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/KeyboardListenerMixin.java new file mode 100644 index 0000000..5cd10cf --- /dev/null +++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/KeyboardListenerMixin.java @@ -0,0 +1,17 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.KeyInputEvent; +import net.minecraft.client.KeyboardListener; +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(KeyboardListener.class) +public class KeyboardListenerMixin { //todo + @Inject(method = "onKeyEvent", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;fireKeyInput(IIII)V")) + private void onKeyEvent(long windowPointer, int key, int scanCode, int action, int modifiers, CallbackInfo ci) { + EventManager.INSTANCE.post(new KeyInputEvent()); + } +} diff --git a/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java new file mode 100644 index 0000000..26ede28 --- /dev/null +++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java @@ -0,0 +1,66 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.*; +import net.minecraft.client.Minecraft; +import net.minecraft.util.Timer; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.eventbus.api.Event; +import org.spongepowered.asm.mixin.Final; +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.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Minecraft.class) +public class MinecraftMixin { + @Final + @Shadow + private Timer timer; + + @Inject(method = "shutdownMinecraftApplet", at = @At("HEAD")) + private void onShutdown(CallbackInfo ci) { + EventManager.INSTANCE.post(new PreShutdownEvent()); + } + + @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/hooks/BasicEventHooks;onRenderTickStart(F)V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onRenderTickStart(CallbackInfo ci) { + EventManager.INSTANCE.post(new RenderEvent(Stage.START, timer.renderPartialTicks)); + } + + @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/hooks/BasicEventHooks;onRenderTickEnd(F)V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onRenderTickEnd(CallbackInfo ci) { + EventManager.INSTANCE.post(new RenderEvent(Stage.END, timer.renderPartialTicks)); + } + + @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/hooks/BasicEventHooks;onPreClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onClientTickStart(CallbackInfo ci) { + EventManager.INSTANCE.post(new TickEvent(Stage.START)); + } + + @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/hooks/BasicEventHooks;onPostClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onClientTickEnd(CallbackInfo ci) { + EventManager.INSTANCE.post(new TickEvent(Stage.END)); + } + + @ModifyArg(method = "displayGuiScreen", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/eventbus/api/IEventBus;post(Lnet/minecraftforge/eventbus/api/Event;)Z", remap = false), remap = true) + private Event onGuiOpenEvent(Event a) { + if (a instanceof GuiOpenEvent) { + GuiOpenEvent forgeEvent = (GuiOpenEvent) a; + ScreenOpenEvent event = new ScreenOpenEvent(forgeEvent.getGui()); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + forgeEvent.setCanceled(true); + } + return forgeEvent; + } + return a; + } + + @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Timer;getPartialTicks(J)I", shift = At.Shift.AFTER)) + private void onDeltaTickTimerUpdate(CallbackInfo ci) { + EventManager.INSTANCE.post(new TimerUpdateEvent(timer, true)); + } +} \ No newline at end of file diff --git a/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseHelperMixin.java b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseHelperMixin.java new file mode 100644 index 0000000..95a5b0c --- /dev/null +++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseHelperMixin.java @@ -0,0 +1,17 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.MouseInputEvent; +import net.minecraft.client.MouseHelper; +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(MouseHelper.class) +public class MouseHelperMixin { //todo + @Inject(method = "mouseButtonCallback", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;fireMouseInput(III)V")) + private void onMouse(long handle, int button, int action, int mods, CallbackInfo ci) { + EventManager.INSTANCE.post(new MouseInputEvent()); + } +} diff --git a/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java new file mode 100644 index 0000000..dfee688 --- /dev/null +++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java @@ -0,0 +1,25 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.ChatReceiveEvent; +import net.minecraft.client.network.play.ClientPlayNetHandler; +import net.minecraft.network.play.server.SChatPacket; +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(value = ClientPlayNetHandler.class, priority = Integer.MAX_VALUE) +public class NetHandlerPlayClientMixin { + + @Inject(method = "handleChat", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/event/ForgeEventFactory;onClientChat(Lnet/minecraft/util/text/ChatType;Lnet/minecraft/util/text/ITextComponent;Ljava/util/UUID;)Lnet/minecraft/util/text/ITextComponent;", remap = false), cancellable = true, remap = true) + private void onClientChat(SChatPacket packetIn, CallbackInfo ci) { + if (packetIn.getType().getId() == 0) { + ChatReceiveEvent event = new ChatReceiveEvent(packetIn.getChatComponent()); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + ci.cancel(); + } + } + } +} \ No newline at end of file diff --git a/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java new file mode 100644 index 0000000..35b987a --- /dev/null +++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java @@ -0,0 +1,42 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.ReceivePacketEvent; +import cc.polyfrost.oneconfig.events.event.SendPacketEvent; +import io.netty.channel.ChannelHandlerContext; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import net.minecraft.network.IPacket; +import net.minecraft.network.NetworkManager; +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(value = NetworkManager.class, priority = Integer.MAX_VALUE) +public class NetworkManagerMixin { + + @Inject(method = "sendPacket(Lnet/minecraft/network/IPacket;Lio/netty/util/concurrent/GenericFutureListener;)V", at = @At("HEAD"), cancellable = true) + private void onSendPacket(IPacket packetIn, GenericFutureListener> genericFutureListener, CallbackInfo ci) { + onSendPacket(packetIn, ci); + } + + @Inject(method = "sendPacket(Lnet/minecraft/network/IPacket;)V", at = @At("HEAD"), cancellable = true) + private void onSendPacket(IPacket packetIn, CallbackInfo ci) { + SendPacketEvent event = new SendPacketEvent(packetIn); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + ci.cancel(); + } + } + + + @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/IPacket;)V", at = @At("HEAD"), cancellable = true) + private void onReceivePacket(ChannelHandlerContext channelHandlerContext, IPacket arg, CallbackInfo ci) { + ReceivePacketEvent event = new ReceivePacketEvent(arg); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + ci.cancel(); + } + } +} \ No newline at end of file diff --git a/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/TimeTrackerMixin.java b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/TimeTrackerMixin.java new file mode 100644 index 0000000..e2d31fe --- /dev/null +++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/TimeTrackerMixin.java @@ -0,0 +1,22 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.ShutdownEvent; +import cc.polyfrost.oneconfig.events.event.StartEvent; +import net.minecraft.profiler.TimeTracker; +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 java.util.function.IntSupplier; +import java.util.function.LongSupplier; + +@Mixin(TimeTracker.class) +public class TimeTrackerMixin { //todo + @Inject(method = "", at = @At("RETURN")) + private void onStart(LongSupplier longSupplier, IntSupplier intSupplier, CallbackInfo ci) { + EventManager.INSTANCE.post(new StartEvent()); + Runtime.getRuntime().addShutdownHook(new Thread(() -> EventManager.INSTANCE.post(new ShutdownEvent()))); + } +} diff --git a/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java new file mode 100644 index 0000000..d98b0db --- /dev/null +++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java @@ -0,0 +1,25 @@ +package cc.polyfrost.oneconfig.internal.mixin; + +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.WorldLoadEvent; +import net.minecraft.client.network.play.ClientPlayNetHandler; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.profiler.IProfiler; +import net.minecraft.util.RegistryKey; +import net.minecraft.world.DimensionType; +import net.minecraft.world.World; +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 java.util.function.Supplier; + +@Mixin(ClientWorld.class) +public class WorldClientMixin { + @Inject(method = "", at = @At("RETURN")) + private void onWorldLoad(ClientPlayNetHandler arg, ClientWorld.ClientWorldInfo arg2, RegistryKey arg3, DimensionType arg4, int i, Supplier supplier, WorldRenderer arg5, boolean bl, long l, CallbackInfo ci) { + EventManager.INSTANCE.post(new WorldLoadEvent()); + } +} \ No newline at end of file diff --git a/versions/1.8.9-1.16.2.txt b/versions/1.8.9-1.16.2.txt deleted file mode 100644 index 1f07e30..0000000 --- a/versions/1.8.9-1.16.2.txt +++ /dev/null @@ -1,19 +0,0 @@ -net.minecraft.util.IChatComponent getUnformattedText() getUnformattedComponentText() -net.minecraft.util.IChatComponent net.minecraft.util.text.ITextComponent -net.minecraft.util.BlockPos net.minecraft.util.math.BlockPos -net.minecraft.client.renderer.WorldRenderer net.minecraft.client.renderer.BufferBuilder -net.minecraft.network.Packet net.minecraft.network.IPacket -net.minecraft.client.gui.GuiScreen net.minecraft.client.gui.screen.Screen -net.minecraft.client.gui.GuiChat net.minecraft.client.gui.screen.ChatScreen -net.minecraft.client.Minecraft getMinecraft() getInstance() -net.minecraft.client.Minecraft isCallingFromMinecraftThread() isOnExecutionThread() -net.minecraft.client.entity.EntityPlayerSP getClientBrand() getServerBrand() -net.minecraft.client.entity.EntityPlayerSP net.minecraft.client.entity.player.ClientPlayerEntity -net.minecraft.launchwrapper.IClassTransformer transform() transformClassBytes() -net.minecraft.launchwrapper.IClassTransformer org.spongepowered.asm.service.ILegacyClassTransformer -net.minecraft.client.Minecraft entityRenderer gameRenderer -net.minecraftforge.fml.common.event.FMLInitializationEvent net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent -net.minecraft.client.shader.ShaderUniform net.minecraft.client.shader.ShaderDefault -net.minecraftforge.fml.common.Loader instance() get() -net.minecraftforge.fml.common.Loader net.minecraftforge.fml.ModLoadingContext -net.minecraftforge.fml.common.ModContainer net.minecraftforge.fml.ModContainer \ No newline at end of file diff --git a/versions/root.gradle.kts b/versions/root.gradle.kts index a35e559..baf8637 100644 --- a/versions/root.gradle.kts +++ b/versions/root.gradle.kts @@ -6,7 +6,8 @@ plugins { preprocess { "1.8.9-forge"(10809, "srg") { - "1.12.2-forge"(11202, "srg", file("1.8.9-1.12.2.txt")) - "1.16.2-forge"(11605, "srg", file("1.8.9-1.16.2.txt")) + "1.12.2-forge"(11202, "srg", file("1.8.9-1.12.2.txt")) { + "1.16.2-forge"(11602, "srg", file("1.12.2-1.16.2.txt")) + } } } \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java index 5b928a8..44a6611 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java @@ -17,7 +17,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.File; -import java.util.ServiceLoader; /** * The main class of OneConfig. diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java index 2a49f74..ebf4f0a 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java @@ -1,20 +1,20 @@ //#if MC==10809 - package cc.polyfrost.oneconfig.internal.mixin; +package cc.polyfrost.oneconfig.internal.mixin; - import cc.polyfrost.oneconfig.events.EventManager; - import cc.polyfrost.oneconfig.events.event.HudRenderEvent; - import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; - import net.minecraftforge.client.GuiIngameForge; - 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 cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.HudRenderEvent; +import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; +import net.minecraftforge.client.GuiIngameForge; +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(value = GuiIngameForge.class, remap = false) - public class GuiIngameForgeMixin { - @Inject(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;post(Lnet/minecraftforge/client/event/RenderGameOverlayEvent$ElementType;)V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onRenderGameOverlay(float partialTicks, CallbackInfo ci) { - EventManager.INSTANCE.post(new HudRenderEvent(new UMatrixStack(), partialTicks)); - } - } +@Mixin(value = GuiIngameForge.class, remap = false) +public class GuiIngameForgeMixin { + @Inject(method = "renderGameOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/GuiIngameForge;post(Lnet/minecraftforge/client/event/RenderGameOverlayEvent$ElementType;)V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onRenderGameOverlay(float partialTicks, CallbackInfo ci) { + EventManager.INSTANCE.post(new HudRenderEvent(new UMatrixStack(), partialTicks)); + } +} //#endif \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java index 46d9bbc..23d7d84 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java @@ -1,100 +1,100 @@ //#if MC==10809 - package cc.polyfrost.oneconfig.internal.mixin; +package cc.polyfrost.oneconfig.internal.mixin; - import cc.polyfrost.oneconfig.internal.OneConfig; - import cc.polyfrost.oneconfig.events.EventManager; - import cc.polyfrost.oneconfig.events.event.*; - import net.minecraft.client.Minecraft; - import net.minecraft.util.Timer; - import net.minecraftforge.client.event.GuiOpenEvent; - import net.minecraftforge.fml.common.eventhandler.Event; - import org.objectweb.asm.Opcodes; - 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.ModifyArg; - import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.*; +import cc.polyfrost.oneconfig.internal.OneConfig; +import net.minecraft.client.Minecraft; +import net.minecraft.util.Timer; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.fml.common.eventhandler.Event; +import org.objectweb.asm.Opcodes; +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.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - @Mixin(Minecraft.class) - public class MinecraftMixin { - @Shadow - private Timer timer; +@Mixin(Minecraft.class) +public class MinecraftMixin { + @Shadow + private Timer timer; - @Inject(method = "shutdownMinecraftApplet", at = @At("HEAD")) - private void onShutdown(CallbackInfo ci) { - EventManager.INSTANCE.post(new PreShutdownEvent()); - } + @Inject(method = "shutdownMinecraftApplet", at = @At("HEAD")) + private void onShutdown(CallbackInfo ci) { + EventManager.INSTANCE.post(new PreShutdownEvent()); + } - @Inject(method = "startGame", at = @At("HEAD")) - private void onStart(CallbackInfo ci) { - EventManager.INSTANCE.post(new StartEvent()); - Runtime.getRuntime().addShutdownHook(new Thread(() -> EventManager.INSTANCE.post(new ShutdownEvent()))); - } + @Inject(method = "startGame", at = @At("HEAD")) + private void onStart(CallbackInfo ci) { + EventManager.INSTANCE.post(new StartEvent()); + Runtime.getRuntime().addShutdownHook(new Thread(() -> EventManager.INSTANCE.post(new ShutdownEvent()))); + } - @Inject(method = "startGame", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;beginMinecraftLoading(Lnet/minecraft/client/Minecraft;Ljava/util/List;Lnet/minecraft/client/resources/IReloadableResourceManager;)V", remap = false), remap = true) - private void onPreLaunch(CallbackInfo ci) { - OneConfig.preLaunch(); - } + @Inject(method = "startGame", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;beginMinecraftLoading(Lnet/minecraft/client/Minecraft;Ljava/util/List;Lnet/minecraft/client/resources/IReloadableResourceManager;)V", remap = false), remap = true) + private void onPreLaunch(CallbackInfo ci) { + OneConfig.preLaunch(); + } - @Inject(method = "startGame", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;onInitializationComplete()V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onInit(CallbackInfo ci) { - EventManager.INSTANCE.post(new InitializationEvent()); - OneConfig.init(); - } + @Inject(method = "startGame", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/client/FMLClientHandler;onInitializationComplete()V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onInit(CallbackInfo ci) { + EventManager.INSTANCE.post(new InitializationEvent()); + OneConfig.init(); + } - @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onRenderTickStart(F)V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onRenderTickStart(CallbackInfo ci) { - EventManager.INSTANCE.post(new RenderEvent(Stage.START, timer.renderPartialTicks)); - } + @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onRenderTickStart(F)V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onRenderTickStart(CallbackInfo ci) { + EventManager.INSTANCE.post(new RenderEvent(Stage.START, timer.renderPartialTicks)); + } - @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onRenderTickEnd(F)V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onRenderTickEnd(CallbackInfo ci) { - EventManager.INSTANCE.post(new RenderEvent(Stage.END, timer.renderPartialTicks)); - } + @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onRenderTickEnd(F)V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onRenderTickEnd(CallbackInfo ci) { + EventManager.INSTANCE.post(new RenderEvent(Stage.END, timer.renderPartialTicks)); + } - @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onPreClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onClientTickStart(CallbackInfo ci) { - EventManager.INSTANCE.post(new TickEvent(Stage.START)); - } + @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onPreClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onClientTickStart(CallbackInfo ci) { + EventManager.INSTANCE.post(new TickEvent(Stage.START)); + } - @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onPostClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) - private void onClientTickEnd(CallbackInfo ci) { - EventManager.INSTANCE.post(new TickEvent(Stage.END)); - } + @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;onPostClientTick()V", shift = At.Shift.AFTER, remap = false), remap = true) + private void onClientTickEnd(CallbackInfo ci) { + EventManager.INSTANCE.post(new TickEvent(Stage.END)); + } - @ModifyArg(method = "displayGuiScreen", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/eventhandler/EventBus;post(Lnet/minecraftforge/fml/common/eventhandler/Event;)Z", remap = false), remap = true) - private Event onGuiOpenEvent(Event a) { - if (a instanceof GuiOpenEvent) { - GuiOpenEvent forgeEvent = (GuiOpenEvent) a; - ScreenOpenEvent event = new ScreenOpenEvent(forgeEvent.gui); - EventManager.INSTANCE.post(event); - if (event.isCancelled) { - forgeEvent.setCanceled(true); - } - return forgeEvent; - } - return a; - } + @ModifyArg(method = "displayGuiScreen", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/eventhandler/EventBus;post(Lnet/minecraftforge/fml/common/eventhandler/Event;)Z", remap = false), remap = true) + private Event onGuiOpenEvent(Event a) { + if (a instanceof GuiOpenEvent) { + GuiOpenEvent forgeEvent = (GuiOpenEvent) a; + ScreenOpenEvent event = new ScreenOpenEvent(forgeEvent.gui); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + forgeEvent.setCanceled(true); + } + return forgeEvent; + } + return a; + } - @Inject(method = "runGameLoop", at = @At(value = "FIELD", target = "Lnet/minecraft/util/Timer;renderPartialTicks:F", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER)) - private void onNonDeltaTickTimerUpdate(CallbackInfo ci) { - EventManager.INSTANCE.post(new TimerUpdateEvent(timer, false)); - } + @Inject(method = "runGameLoop", at = @At(value = "FIELD", target = "Lnet/minecraft/util/Timer;renderPartialTicks:F", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER)) + private void onNonDeltaTickTimerUpdate(CallbackInfo ci) { + EventManager.INSTANCE.post(new TimerUpdateEvent(timer, false)); + } - @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Timer;updateTimer()V", shift = At.Shift.AFTER, ordinal = 1)) - private void onDeltaTickTimerUpdate(CallbackInfo ci) { - EventManager.INSTANCE.post(new TimerUpdateEvent(timer, true)); - } + @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Timer;updateTimer()V", shift = At.Shift.AFTER, ordinal = 1)) + private void onDeltaTickTimerUpdate(CallbackInfo ci) { + EventManager.INSTANCE.post(new TimerUpdateEvent(timer, true)); + } - @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;fireKeyInput()V")) - private void onKeyEvent(CallbackInfo ci) { - EventManager.INSTANCE.post(new KeyInputEvent()); - } + @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;fireKeyInput()V")) + private void onKeyEvent(CallbackInfo ci) { + EventManager.INSTANCE.post(new KeyInputEvent()); + } - @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;fireMouseInput()V")) - private void onMouseEvent(CallbackInfo ci) { - EventManager.INSTANCE.post(new MouseInputEvent()); - } - } + @Inject(method = "runTick", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/FMLCommonHandler;fireMouseInput()V")) + private void onMouseEvent(CallbackInfo ci) { + EventManager.INSTANCE.post(new MouseInputEvent()); + } +} //#endif \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java index 0496e98..5ae6730 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java @@ -1,38 +1,29 @@ //#if MC==10809 - package cc.polyfrost.oneconfig.internal.mixin; +package cc.polyfrost.oneconfig.internal.mixin; - import cc.polyfrost.oneconfig.events.EventManager; - import cc.polyfrost.oneconfig.events.event.ChatReceiveEvent; - import cc.polyfrost.oneconfig.events.event.SendPacketEvent; - import net.minecraft.client.network.NetHandlerPlayClient; - import net.minecraft.network.Packet; - import net.minecraft.network.play.server.S02PacketChat; - 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 cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.ChatReceiveEvent; +import cc.polyfrost.oneconfig.events.event.SendPacketEvent; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S02PacketChat; +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(value = NetHandlerPlayClient.class, priority = Integer.MAX_VALUE) - public class NetHandlerPlayClientMixin { +@Mixin(value = NetHandlerPlayClient.class, priority = Integer.MAX_VALUE) +public class NetHandlerPlayClientMixin { - @Inject(method = "addToSendQueue", at = @At("HEAD"), cancellable = true) - private void onSendPacket(Packet p_147297_1_, CallbackInfo ci) { - SendPacketEvent event = new SendPacketEvent(p_147297_1_); - EventManager.INSTANCE.post(event); - if (event.isCancelled) { - ci.cancel(); - } - } - - @Inject(method = "handleChat", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/event/ForgeEventFactory;onClientChat(BLnet/minecraft/util/IChatComponent;)Lnet/minecraft/util/IChatComponent;", remap = false), cancellable = true, remap = true) - private void onClientChat(S02PacketChat packetIn, CallbackInfo ci) { - if (packetIn.getType() == 0) { - ChatReceiveEvent event = new ChatReceiveEvent(packetIn.getChatComponent()); - EventManager.INSTANCE.post(event); - if (event.isCancelled) { - ci.cancel(); - } - } - } - } + @Inject(method = "handleChat", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/event/ForgeEventFactory;onClientChat(BLnet/minecraft/util/IChatComponent;)Lnet/minecraft/util/IChatComponent;", remap = false), cancellable = true, remap = true) + private void onClientChat(S02PacketChat packetIn, CallbackInfo ci) { + if (packetIn.getType() == 0) { + ChatReceiveEvent event = new ChatReceiveEvent(packetIn.getChatComponent()); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + ci.cancel(); + } + } + } +} //#endif \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java index ac81645..5b99446 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java @@ -1,25 +1,43 @@ //#if MC==10809 - package cc.polyfrost.oneconfig.internal.mixin; +package cc.polyfrost.oneconfig.internal.mixin; - import cc.polyfrost.oneconfig.events.EventManager; - import cc.polyfrost.oneconfig.events.event.ReceivePacketEvent; - import io.netty.channel.ChannelHandlerContext; - import net.minecraft.network.NetworkManager; - import net.minecraft.network.Packet; - 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 cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.ReceivePacketEvent; +import cc.polyfrost.oneconfig.events.event.SendPacketEvent; +import io.netty.channel.ChannelHandlerContext; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +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(value = NetworkManager.class, priority = Integer.MAX_VALUE) - public class NetworkManagerMixin { - @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) - private void onReceivePacket(ChannelHandlerContext p_channelRead0_1_, Packet p_channelRead0_2_, CallbackInfo ci) { - ReceivePacketEvent event = new ReceivePacketEvent(p_channelRead0_2_); - EventManager.INSTANCE.post(event); - if (event.isCancelled) { - ci.cancel(); - } - } - } +@Mixin(value = NetworkManager.class, priority = Integer.MAX_VALUE) +public class NetworkManagerMixin { + + @Inject(method = "sendPacket(Lnet/minecraft/network/Packet;Lio/netty/util/concurrent/GenericFutureListener;[Lio/netty/util/concurrent/GenericFutureListener;)V", at = @At("HEAD"), cancellable = true) + private void onSendPacket(Packet packetIn, GenericFutureListener> listener, GenericFutureListener>[] listeners, CallbackInfo ci) { + onSendPacket(packetIn, ci); + } + + @Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) + private void onSendPacket(Packet packetIn, CallbackInfo ci) { + SendPacketEvent event = new SendPacketEvent(packetIn); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + ci.cancel(); + } + } + + @Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true) + private void onReceivePacket(ChannelHandlerContext p_channelRead0_1_, Packet p_channelRead0_2_, CallbackInfo ci) { + ReceivePacketEvent event = new ReceivePacketEvent(p_channelRead0_2_); + EventManager.INSTANCE.post(event); + if (event.isCancelled) { + ci.cancel(); + } + } +} //#endif \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/OptifineConfigMixin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/OptifineConfigMixin.java index 3794daf..eb6fc03 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/OptifineConfigMixin.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/OptifineConfigMixin.java @@ -1,23 +1,21 @@ -//#if MC==10809 - package cc.polyfrost.oneconfig.internal.mixin; +package cc.polyfrost.oneconfig.internal.mixin; - import cc.polyfrost.oneconfig.internal.plugin.hooks.OptifineConfigHook; - import org.spongepowered.asm.mixin.Dynamic; - import org.spongepowered.asm.mixin.Mixin; - import org.spongepowered.asm.mixin.Pseudo; - import org.spongepowered.asm.mixin.injection.At; - import org.spongepowered.asm.mixin.injection.Inject; - import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import cc.polyfrost.oneconfig.internal.plugin.hooks.OptifineConfigHook; +import org.spongepowered.asm.mixin.Dynamic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - @Pseudo - @Mixin(targets = "Config", remap = false) - public class OptifineConfigMixin { - @Dynamic("OptiFine") - @Inject(method = "isFastRender", at = @At("HEAD"), cancellable = true) - private static void cancelFastRender(CallbackInfoReturnable cir) { - if (OptifineConfigHook.shouldNotApplyFastRender()) { - cir.setReturnValue(false); - } - } - } -//#endif \ No newline at end of file +@Pseudo +@Mixin(targets = "Config", remap = false) +public class OptifineConfigMixin { + @Dynamic("OptiFine") + @Inject(method = "isFastRender", at = @At("HEAD"), cancellable = true) + private static void cancelFastRender(CallbackInfoReturnable cir) { + if (OptifineConfigHook.shouldNotApplyFastRender()) { + cir.setReturnValue(false); + } + } +} \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java index 11a5590..04e3fe9 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java @@ -1,10 +1,8 @@ -//#if MC==10809 - package cc.polyfrost.oneconfig.internal.mixin; +package cc.polyfrost.oneconfig.internal.mixin; - import gg.essential.vigilance.Vigilant; - import org.spongepowered.asm.mixin.Mixin; +import gg.essential.vigilance.Vigilant; +import org.spongepowered.asm.mixin.Mixin; - @Mixin(Vigilant.class) - public class VigilantMixin { - } -//#endif \ No newline at end of file +@Mixin(Vigilant.class) +public class VigilantMixin { +} \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java index fbf39fc..05c6920 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java @@ -1,23 +1,23 @@ //#if MC==10809 - package cc.polyfrost.oneconfig.internal.mixin; +package cc.polyfrost.oneconfig.internal.mixin; - import cc.polyfrost.oneconfig.events.EventManager; - import cc.polyfrost.oneconfig.events.event.WorldLoadEvent; - import net.minecraft.client.multiplayer.WorldClient; - import net.minecraft.client.network.NetHandlerPlayClient; - import net.minecraft.profiler.Profiler; - import net.minecraft.world.EnumDifficulty; - import net.minecraft.world.WorldSettings; - 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 cc.polyfrost.oneconfig.events.EventManager; +import cc.polyfrost.oneconfig.events.event.WorldLoadEvent; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.profiler.Profiler; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.WorldSettings; +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(WorldClient.class) - public class WorldClientMixin { - @Inject(method = "", at = @At("RETURN")) - private void onWorldLoad(NetHandlerPlayClient p_i45063_1_, WorldSettings p_i45063_2_, int p_i45063_3_, EnumDifficulty p_i45063_4_, Profiler p_i45063_5_, CallbackInfo ci) { - EventManager.INSTANCE.post(new WorldLoadEvent()); - } - } +@Mixin(WorldClient.class) +public class WorldClientMixin { + @Inject(method = "", at = @At("RETURN")) + private void onWorldLoad(NetHandlerPlayClient p_i45063_1_, WorldSettings p_i45063_2_, int p_i45063_3_, EnumDifficulty p_i45063_4_, Profiler p_i45063_5_, CallbackInfo ci) { + EventManager.INSTANCE.post(new WorldLoadEvent()); + } +} //#endif \ No newline at end of file -- cgit