aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-07-02 07:12:29 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-07-02 07:12:29 +0700
commit0979e8243cd18195508a93bdcb3319fdf22bcf70 (patch)
tree89b0b82b991a0d31537f663236fdad22f2a34c2f
parentbdb778c8c1387c802927625cdf5192d99295ca4e (diff)
downloadOneConfig-0979e8243cd18195508a93bdcb3319fdf22bcf70.tar.gz
OneConfig-0979e8243cd18195508a93bdcb3319fdf22bcf70.tar.bz2
OneConfig-0979e8243cd18195508a93bdcb3319fdf22bcf70.zip
ez 1.12 support
-rw-r--r--gradle.properties2
-rw-r--r--settings.gradle.kts3
-rw-r--r--versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java17
-rw-r--r--versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java94
-rw-r--r--versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java36
-rw-r--r--versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java23
-rw-r--r--versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/OptifineConfigMixin.java21
-rw-r--r--versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ShaderGroupAccessor.java14
-rw-r--r--versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java8
-rw-r--r--versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java21
-rw-r--r--versions/1.8.9-1.12.2.txt5
-rw-r--r--versions/root.gradle.kts4
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/utils/commands/PlatformCommandManagerImpl.java16
13 files changed, 259 insertions, 5 deletions
diff --git a/gradle.properties b/gradle.properties
index f568977..47a5aee 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,6 +1,6 @@
mod_name = OneConfig
mod_id = oneconfig
-mod_version = 0.1.0-alpha41
+mod_version = 0.1.0-alpha42
essential.defaults.loom=0
diff --git a/settings.gradle.kts b/settings.gradle.kts
index ac6c4ea..a78ecd3 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -34,7 +34,8 @@ project(":platform").apply {
}
listOf(
- "1.8.9-forge"
+ "1.8.9-forge",
+ "1.12.2-forge"
).forEach { version ->
include(":platform:$version")
project(":platform:$version").apply {
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..6c615c8
--- /dev/null
+++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java
@@ -0,0 +1,17 @@
+package cc.polyfrost.oneconfig.internal.mixin;
+
+import cc.polyfrost.oneconfig.events.EventManager;
+import cc.polyfrost.oneconfig.events.event.HudRenderEvent;
+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(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..5b54e8e
--- /dev/null
+++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java
@@ -0,0 +1,36 @@
+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
new file mode 100644
index 0000000..7ddaf80
--- /dev/null
+++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java
@@ -0,0 +1,23 @@
+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
new file mode 100644
index 0000000..eb6fc03
--- /dev/null
+++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/OptifineConfigMixin.java
@@ -0,0 +1,21 @@
+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<Boolean> 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
new file mode 100644
index 0000000..2ec0024
--- /dev/null
+++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ShaderGroupAccessor.java
@@ -0,0 +1,14 @@
+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<Shader> 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
new file mode 100644
index 0000000..04e3fe9
--- /dev/null
+++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java
@@ -0,0 +1,8 @@
+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
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 = "<init>", 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.8.9-1.12.2.txt b/versions/1.8.9-1.12.2.txt
new file mode 100644
index 0000000..a6afcb4
--- /dev/null
+++ b/versions/1.8.9-1.12.2.txt
@@ -0,0 +1,5 @@
+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.command.ICommand getCommandName() getName()
+net.minecraft.command.ICommand getCommandUsage() getUsage() \ No newline at end of file
diff --git a/versions/root.gradle.kts b/versions/root.gradle.kts
index f23a159..20d3be6 100644
--- a/versions/root.gradle.kts
+++ b/versions/root.gradle.kts
@@ -5,5 +5,7 @@ plugins {
}
preprocess {
- "1.8.9-forge"(10809, "srg") {}
+ "1.8.9-forge"(10809, "srg") {
+ "1.12.2-forge"(11202, "srg", file("1.8.9-1.12.2.txt"))
+ }
} \ No newline at end of file
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/utils/commands/PlatformCommandManagerImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/utils/commands/PlatformCommandManagerImpl.java
index 8b6edcc..76dab84 100644
--- a/versions/src/main/java/cc/polyfrost/oneconfig/utils/commands/PlatformCommandManagerImpl.java
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/utils/commands/PlatformCommandManagerImpl.java
@@ -39,7 +39,13 @@ public class PlatformCommandManagerImpl implements PlatformCommandManager {
}
@Override
- public void processCommand(ICommandSender sender, String[] args) {
+ public void
+ //#if MC<=10809
+ processCommand(ICommandSender sender, String[] args)
+ //#else
+ //$$ execute(net.minecraft.server.MinecraftServer server, ICommandSender sender, String[] args)
+ //#endif
+ {
handleCommand(root, annotation, args);
}
@@ -49,7 +55,13 @@ public class PlatformCommandManagerImpl implements PlatformCommandManager {
}
@Override
- public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
+ public List<String>
+ //#if MC<=10809
+ addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
+ //#else
+ //$$ getTabCompletions(net.minecraft.server.MinecraftServer server, ICommandSender sender, String[] args, BlockPos targetPos)
+ //#endif
+ {
return handleTabCompletion(root, annotation, args);
}
});