aboutsummaryrefslogtreecommitdiff
path: root/versions
diff options
context:
space:
mode:
Diffstat (limited to 'versions')
-rw-r--r--versions/1.12.2-1.16.2.txt30
-rw-r--r--versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java11
-rw-r--r--versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java19
-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.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ClientModLoaderMixin.java24
-rw-r--r--versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/GuiIngameForgeMixin.java19
-rw-r--r--versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/KeyboardListenerMixin.java17
-rw-r--r--versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java66
-rw-r--r--versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseHelperAccessor.java11
-rw-r--r--versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseHelperMixin.java17
-rw-r--r--versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java25
-rw-r--r--versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java42
-rw-r--r--versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/TimeTrackerMixin.java22
-rw-r--r--versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/WorldClientMixin.java25
-rw-r--r--versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/utils/commands/PlatformCommandManagerImpl.java123
-rw-r--r--versions/build.gradle.kts61
-rw-r--r--versions/root.gradle.kts4
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java18
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java17
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java2
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetHandlerPlayClientMixin.java9
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/NetworkManagerMixin.java18
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/OptifineConfigMixin.java4
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ShaderGroupAccessor.java4
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/VigilantMixin.java4
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java140
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ClassTransformer.java5
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/OneConfigTweaker.java4
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java23
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/LoaderPlatformImpl.java14
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/MousePlatformImpl.java65
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/PlatformImpl.java29
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/test/TestMod_Test.java14
-rw-r--r--versions/src/main/java/cc/polyfrost/oneconfig/utils/commands/PlatformCommandManagerImpl.java332
-rw-r--r--versions/src/main/resources/META-INF/mods.toml30
-rw-r--r--versions/src/main/resources/pack.mcmeta7
38 files changed, 961 insertions, 337 deletions
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..5d0f09b
--- /dev/null
+++ b/versions/1.12.2-1.16.2.txt
@@ -0,0 +1,30 @@
+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.minecraft.client.shader.ShaderUniform net.minecraft.client.shader.ShaderDefault
+
+net.minecraftforge.fml.common.event.FMLInitializationEvent net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
+net.minecraftforge.fml.common.Loader instance() get()
+net.minecraftforge.fml.common.Loader activeModContainer() getActiveContainer()
+net.minecraftforge.fml.common.Loader net.minecraftforge.fml.ModLoadingContext
+net.minecraftforge.fml.common.ModContainer net.minecraftforge.fml.ModContainer
+
+org.spongepowered.asm.lib.tree.ClassNode org.objectweb.asm.tree.ClassNode
+org.spongepowered.asm.lib.tree.FieldNode org.objectweb.asm.tree.FieldNode
+org.spongepowered.asm.lib.tree.MethodNode org.objectweb.asm.tree.MethodNode
+org.spongepowered.asm.lib.tree.LabelNode org.objectweb.asm.tree.LabelNode
+org.spongepowered.asm.lib.tree.LineNumberNode org.objectweb.asm.tree.LineNumberNode
+org.spongepowered.asm.lib.tree.VarInsnNode org.objectweb.asm.tree.VarInsnNode
+org.spongepowered.asm.lib.tree.FieldInsnNode org.objectweb.asm.tree.FieldInsnNode
+org.spongepowered.asm.lib.tree.MethodInsnNode org.objectweb.asm.tree.MethodInsnNode
+org.spongepowered.asm.lib.tree.InsnList org.objectweb.asm.tree.InsnList
+org.spongepowered.asm.lib.tree.InsnNode org.objectweb.asm.tree.InsnNode
+org.spongepowered.asm.lib.tree.JumpInsnNode org.objectweb.asm.tree.JumpInsnNode \ 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
index 5b54e8e..d2a68ff 100644
--- 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
@@ -2,9 +2,7 @@ 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;
@@ -14,15 +12,6 @@ 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) {
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
index 7ddaf80..023fdaa 100644
--- 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
@@ -2,7 +2,10 @@ 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;
@@ -12,6 +15,22 @@ 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<? extends Future<? super Void>> listener, GenericFutureListener<? extends Future<? super Void>>[] 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_);
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<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
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<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
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.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..b0caed6
--- /dev/null
+++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ClientModLoaderMixin.java
@@ -0,0 +1,24 @@
+package cc.polyfrost.oneconfig.internal.mixin;
+
+import cc.polyfrost.oneconfig.events.EventManager;
+import cc.polyfrost.oneconfig.events.event.InitializationEvent;
+import cc.polyfrost.oneconfig.internal.OneConfig;
+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 {
+ @Inject(method = "begin", at = @At("HEAD"))
+ private static void onBegin(CallbackInfo ci) {
+ OneConfig.preLaunch();
+ }
+
+ @Inject(method = "lambda$finishModLoading$9", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/GameSettings;loadOptions()V"))
+ 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..c7e6327
--- /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 {
+ @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/MouseHelperAccessor.java b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseHelperAccessor.java
new file mode 100644
index 0000000..d04ecb1
--- /dev/null
+++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MouseHelperAccessor.java
@@ -0,0 +1,11 @@
+package cc.polyfrost.oneconfig.internal.mixin;
+
+import net.minecraft.client.MouseHelper;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+@Mixin(MouseHelper.class)
+public interface MouseHelperAccessor {
+ @Accessor
+ double getAccumulatedScrollDelta();
+}
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..42dd283
--- /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 {
+ @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<? extends Future<? super Void>> 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..dd9920e
--- /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 {
+ @Inject(method = "<init>", 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 = "<init>", at = @At("RETURN"))
+ private void onWorldLoad(ClientPlayNetHandler arg, ClientWorld.ClientWorldInfo arg2, RegistryKey<World> arg3, DimensionType arg4, int i, Supplier<IProfiler> 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.16.2-forge/src/main/java/cc/polyfrost/oneconfig/utils/commands/PlatformCommandManagerImpl.java b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/utils/commands/PlatformCommandManagerImpl.java
new file mode 100644
index 0000000..81bc9b2
--- /dev/null
+++ b/versions/1.16.2-forge/src/main/java/cc/polyfrost/oneconfig/utils/commands/PlatformCommandManagerImpl.java
@@ -0,0 +1,123 @@
+package cc.polyfrost.oneconfig.utils.commands;
+
+import cc.polyfrost.oneconfig.libs.universal.ChatColor;
+import cc.polyfrost.oneconfig.libs.universal.UChat;
+import cc.polyfrost.oneconfig.utils.commands.annotations.Command;
+import cc.polyfrost.oneconfig.utils.commands.annotations.Greedy;
+import cc.polyfrost.oneconfig.utils.commands.arguments.ArgumentParser;
+import cc.polyfrost.oneconfig.utils.commands.arguments.Arguments;
+import com.mojang.brigadier.StringReader;
+import com.mojang.brigadier.arguments.ArgumentType;
+import com.mojang.brigadier.builder.LiteralArgumentBuilder;
+import com.mojang.brigadier.context.CommandContext;
+import com.mojang.brigadier.suggestion.Suggestions;
+import com.mojang.brigadier.suggestion.SuggestionsBuilder;
+import net.minecraft.command.CommandSource;
+import net.minecraft.command.Commands;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.Pair;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Parameter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.concurrent.CompletableFuture;
+
+import static cc.polyfrost.oneconfig.utils.commands.CommandManager.METHOD_RUN_ERROR;
+
+public class PlatformCommandManagerImpl extends PlatformCommandManager {
+
+ final HashMap<Class<?>, Pair<ArgumentType<Object>, ArgumentType<Object>>> parsers = new HashMap<>(); // non-greedy, greedy
+
+ @Override
+ void createCommand(CommandManager.InternalCommand root, Command annotation) {
+ LiteralArgumentBuilder<CommandSource> builder = Commands.literal(annotation.value());
+ if (!root.invokers.isEmpty()) {
+ builder.executes((context ->
+ {
+ try {
+ root.invokers.get(0).method.invoke(null);
+ return 1;
+ } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException |
+ ExceptionInInitializerError e) {
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR);
+ return 0;
+ }
+ }));
+ }
+ if (annotation.helpCommand()) {
+ builder.then(Commands.literal("help").executes((context ->
+ {
+ UChat.chat(sendHelpCommand(root));
+ return 1;
+ })));
+ }
+ for (CommandManager.InternalCommand command : root.children) {
+ loopThroughChildren(command, builder, null);
+ }
+ }
+
+ private void loopThroughChildren(CommandManager.InternalCommand command, LiteralArgumentBuilder<CommandSource> root, LiteralArgumentBuilder<CommandSource> builder) {
+ if (command.invokers.isEmpty() || command.children.isEmpty()) return;
+ if (builder == null) {
+ builder = root.then(Commands.literal(command.name));
+ } else {
+ builder = builder.then(Commands.literal(command.name));
+ }
+ for (CommandManager.InternalCommand.InternalCommandInvoker invoker : command.invokers) {
+ for (Parameter parameter : invoker.method.getParameters()) {
+ Pair<ArgumentType<Object>, ArgumentType<Object>> pair = parsers.get(parameter.getType());
+ builder.then(Commands.argument(parameter.getName(), parameter.isAnnotationPresent(Greedy.class) ? pair.getRight() : pair.getLeft()));
+ }
+ builder.executes((context ->
+ {
+ try {
+ ArrayList<Object> args = new ArrayList<>(invoker.method.getParameterCount());
+ for (Parameter parameter: invoker.method.getParameters()) {
+ args.add(context.getArgument(parameter.getName(), Object.class));
+ }
+ invoker.method.invoke(null, args);
+ return 1;
+ } catch (Exception e) {
+ e.printStackTrace();
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR);
+ return 0;
+ }
+ }));
+ }
+ for (CommandManager.InternalCommand child : command.children) {
+ loopThroughChildren(child, root, builder);
+ }
+ }
+
+ @Override
+ public void handleNewParser(ArgumentParser<?> parser, Class<?> clazz) {
+ parsers.put(clazz, new ImmutablePair<ArgumentType<Object>, ArgumentType<Object>>(new ArgumentType() {
+
+ @Override
+ public Object parse(StringReader reader) {
+ final String text = reader.getRemaining();
+ reader.setCursor(reader.getTotalLength());
+ return parser.parse(new Arguments(text.split("\\s+"), false));
+ }
+
+ @Override
+ public CompletableFuture<Suggestions> listSuggestions(CommandContext context, SuggestionsBuilder builder) {
+ return ArgumentType.super.listSuggestions(context, builder);
+ }
+ }, new ArgumentType() {
+
+ @Override
+ public Object parse(StringReader reader) {
+ final String text = reader.getRemaining();
+ reader.setCursor(reader.getTotalLength());
+ return parser.parse(new Arguments(text.split("\\s+"), true));
+ }
+
+ @Override
+ public CompletableFuture<Suggestions> listSuggestions(CommandContext context, SuggestionsBuilder builder) {
+ return ArgumentType.super.listSuggestions(context, builder);
+ }
+ }));
+ }
+}
diff --git a/versions/build.gradle.kts b/versions/build.gradle.kts
index 1863fd4..b140fbd 100644
--- a/versions/build.gradle.kts
+++ b/versions/build.gradle.kts
@@ -2,6 +2,7 @@ import gg.essential.gradle.util.RelocationTransform.Companion.registerRelocation
import gg.essential.gradle.util.noServerRunConfigs
import gg.essential.gradle.util.prebundle
import net.fabricmc.loom.task.RemapSourcesJarTask
+import java.text.SimpleDateFormat
plugins {
@@ -47,11 +48,15 @@ base {
}
loom {
noServerRunConfigs()
- if (project.platform.isLegacyForge) {
- launchConfigs.named("client") {
+ launchConfigs.named("client") {
+ if (project.platform.isLegacyForge) {
arg("--tweakClass", "cc.polyfrost.oneconfig.internal.plugin.asm.OneConfigTweaker")
- property("mixin.debug.export", "true")
- property("debugBytecode", "true")
+ }
+ property("mixin.debug.export", "true")
+ property("debugBytecode", "true")
+ property("forge.logging.console.level", "debug")
+ if (org.gradle.internal.os.OperatingSystem.current().isMacOsX) {
+ property("fml.earlyprogresswindow", "false")
}
}
if (project.platform.isForge) {
@@ -59,6 +64,9 @@ loom {
mixinConfig("mixins.${mod_id}.json")
}
}
+ log4jConfigs.asFileTree.files.forEach {
+ it.writeText(it.readText().replace("warn", "debug"))
+ }
mixin.defaultRefmapName.set("mixins.${mod_id}.refmap.json")
}
@@ -85,10 +93,13 @@ val shade: Configuration by configurations.creating {
}
val shadeNoPom: Configuration by configurations.creating
+val shadeNoPom2: Configuration by configurations.creating
sourceSets {
main {
- output.setResourcesDir(java.classesDirectory)
+ if (project.platform.isForge) {
+ output.setResourcesDir(java.classesDirectory)
+ }
}
}
@@ -105,8 +116,7 @@ dependencies {
isTransitive = false
}
- @Suppress("GradlePackageUpdate")
- shadeRelocated("com.github.ben-manes.caffeine:caffeine:2.9.3")
+ @Suppress("GradlePackageUpdate") shadeRelocated("com.github.ben-manes.caffeine:caffeine:2.9.3")
// for other mods and universalcraft
val kotlinVersion: String by project
@@ -126,14 +136,19 @@ dependencies {
shade("org.jetbrains.kotlinx:kotlinx-serialization-cbor-jvm:$serializationVersion")
shade("org.jetbrains.kotlinx:atomicfu-jvm:$atomicfuVersion")
- shade("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
- isTransitive = false
+ if (platform.isLegacyForge) {
+ shade("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
+ isTransitive = false
+ }
}
shadeNoPom(project(":")) {
isTransitive = false
}
shade("cc.polyfrost:lwjgl:1.0.0-alpha1")
- shadeNoPom(prebundle(shadeRelocated))
+ val prebundled = prebundle(shadeRelocated)
+ modCompileOnly(prebundled)
+ modRuntimeOnly(prebundled)
+ shadeNoPom2(prebundled)
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.6.21")
@@ -155,7 +170,7 @@ tasks {
inputs.property("java_level", compatLevel)
inputs.property("version", mod_version)
inputs.property("mcVersionStr", project.platform.mcVersionStr)
- filesMatching(listOf("mcmod.info", "mixins.${mod_id}.json", "mods.toml")) {
+ filesMatching(listOf("mcmod.info", "mixins.${mod_id}.json", "**/mods.toml")) {
expand(
mapOf(
"id" to mod_id,
@@ -184,11 +199,11 @@ tasks {
withType(Jar::class.java) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
if (project.platform.isFabric) {
- exclude("mcmod.info", "mods.toml")
+ exclude("mcmod.info", "META-INF/mods.toml")
} else {
exclude("fabric.mod.json")
if (project.platform.isLegacyForge) {
- exclude("mods.toml")
+ exclude("**/mods.toml")
exclude("META-INF/versions/**")
exclude("**/module-info.class")
exclude("**/package-info.class")
@@ -204,7 +219,7 @@ tasks {
val shadowJar = named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
archiveClassifier.set("full-dev")
- configurations = listOf(shade, shadeNoPom)
+ configurations = listOf(shade, shadeNoPom, shadeNoPom2)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(jar)
}
@@ -219,8 +234,9 @@ tasks {
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
- dependsOn(shadeNoPom)
- from(shadeNoPom.map { if (it.isDirectory) it else zipTree(it) })
+ dependsOn(shadeNoPom, shadeNoPom2)
+ from(ArrayList<File>().run { addAll(shadeNoPom); addAll(shadeNoPom2); this }
+ .map { if (it.isDirectory) it else zipTree(it) })
manifest {
attributes(
mapOf(
@@ -228,10 +244,21 @@ tasks {
"ForceLoadAsMod" to true,
"TweakOrder" to "0",
"MixinConfigs" to "mixins.oneconfig.json",
- "TweakClass" to "cc.polyfrost.oneconfig.internal.plugin.asm.OneConfigTweaker"
+ "TweakClass" to "cc.polyfrost.oneconfig.internal.plugin.asm.OneConfigTweaker",
+ "FMLModType" to "LIBRARY",
+ "Specification-Title" to mod_id,
+ "Specification-Vendor" to mod_id,
+ "Specification-Version" to "1", // We are version 1 of ourselves, whatever the hell that means
+ "Implementation-Title" to mod_name,
+ "Implementation-Version" to mod_version,
+ "Implementation-Vendor" to mod_id,
+ "Implementation-Timestamp" to SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(`java.util`.Date())
)
)
}
+ /*/
+
+ */
excludeInternal()
archiveClassifier.set("")
}
diff --git a/versions/root.gradle.kts b/versions/root.gradle.kts
index 20d3be6..baf8637 100644
--- a/versions/root.gradle.kts
+++ b/versions/root.gradle.kts
@@ -6,6 +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.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 7ecfe98..4f73198 100644
--- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/OneConfig.java
@@ -17,12 +17,15 @@ 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.
*/
+//#if MC<=11202
@net.minecraftforge.fml.common.Mod(modid = "@ID@", name = "@NAME@", version = "@VER@")
+//#else
+//$$ @net.minecraftforge.fml.common.Mod("@ID@")
+//#endif
public class OneConfig {
public OneConfig() {
@@ -33,7 +36,6 @@ public class OneConfig {
public static final Logger LOGGER = LogManager.getLogger("@NAME@");
private static boolean preLaunched = false;
private static boolean initialized = false;
- private static boolean isObfuscated = true;
/**
* Called before mods are loaded.
@@ -41,12 +43,6 @@ public class OneConfig {
*/
public static void preLaunch() {
if (preLaunched) return;
- try {
- Class.forName("net.minecraft.world.World");
- LOGGER.warn("OneConfig is NOT obfuscated!");
- isObfuscated = false;
- } catch (Exception ignored) {
- }
oneConfigDir.mkdirs();
new File(oneConfigDir, "profiles").mkdirs();
if (OneConfigConfig.getInstance() == null) {
@@ -80,12 +76,6 @@ public class OneConfig {
initialized = true;
}
- /** Returns weather this is an obfuscated environment, using a check for obfuscated name of net.minecraft.world.World.class.
- * @return true if this is an obfuscated environment, which is normal for Minecraft or false if not. */
- public static boolean isObfuscated() {
- return isObfuscated;
- }
-
@Subscribe
private void onShutdown(ShutdownEvent event) {
ConfigCore.saveAll();
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java
index 0ef5f2b..3424d2b 100644
--- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/gui/impl/BlurHandlerImpl.java
@@ -10,7 +10,6 @@ import cc.polyfrost.oneconfig.internal.mixin.ShaderGroupAccessor;
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
import cc.polyfrost.oneconfig.libs.universal.UScreen;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.shader.Shader;
import net.minecraft.client.shader.ShaderUniform;
import net.minecraft.util.ResourceLocation;
@@ -55,7 +54,7 @@ public class BlurHandlerImpl implements BlurHandler {
}
// Only update the shader if one is active
- if (!UMinecraft.getMinecraft().entityRenderer.isShaderActive()) {
+ if (!isShaderActive()) {
return;
}
if (progress >= 5) return;
@@ -65,7 +64,7 @@ public class BlurHandlerImpl implements BlurHandler {
// Why is this being computed every tick? Surely there is a better way?
// This needs to be optimized.
try {
- final List<Shader> listShaders = ((ShaderGroupAccessor) Minecraft.getMinecraft().entityRenderer.getShaderGroup()).getListShaders();
+ final List<Shader> listShaders = ((ShaderGroupAccessor) UMinecraft.getMinecraft().entityRenderer.getShaderGroup()).getListShaders();
// Should not happen. Something bad happened.
if (listShaders == null) {
@@ -102,14 +101,14 @@ public class BlurHandlerImpl implements BlurHandler {
// If a shader is not already active and the UI is
// a one of ours, we should load our own blur!
- if (!UMinecraft.getMinecraft().entityRenderer.isShaderActive() && gui instanceof OneConfigGui && Preferences.enableBlur) {
+ if (!isShaderActive() && gui instanceof OneConfigGui && Preferences.enableBlur) {
UMinecraft.getMinecraft().entityRenderer.loadShader(this.blurShader);
this.start = System.currentTimeMillis();
this.progress = 0;
// If a shader is active and the incoming UI is null or we have blur disabled, stop using the shader.
- } else if (UMinecraft.getMinecraft().entityRenderer.isShaderActive() && (gui == null || !Preferences.enableBlur)) {
+ } else if (isShaderActive() && (gui == null || !Preferences.enableBlur)) {
String name = UMinecraft.getMinecraft().entityRenderer.getShaderGroup().getShaderGroupName();
// Only stop our specific blur ;)
@@ -129,4 +128,12 @@ public class BlurHandlerImpl implements BlurHandler {
private float getBlurStrengthProgress() {
return Math.min((System.currentTimeMillis() - this.start) / 50F, 5.0F);
}
+
+ private boolean isShaderActive() {
+ return UMinecraft.getMinecraft().entityRenderer.getShaderGroup() != null
+ //#if MC<=11202
+ && net.minecraft.client.renderer.OpenGlHelper.shadersSupported
+ //#endif
+ ;
+ }
}
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 0603d12..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,9 +1,9 @@
//#if MC==10809
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 cc.polyfrost.oneconfig.internal.OneConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.util.Timer;
import net.minecraftforge.client.event.GuiOpenEvent;
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 7a446c7..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
@@ -15,15 +15,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@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) {
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 3da0c91..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
@@ -3,7 +3,10 @@ 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;
@@ -13,6 +16,21 @@ 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<? extends Future<? super Void>> listener, GenericFutureListener<? extends Future<? super Void>>[] 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_);
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 9012091..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,4 +1,3 @@
-//#if MC==10809
package cc.polyfrost.oneconfig.internal.mixin;
import cc.polyfrost.oneconfig.internal.plugin.hooks.OptifineConfigHook;
@@ -19,5 +18,4 @@ public class OptifineConfigMixin {
cir.setReturnValue(false);
}
}
-}
-//#endif \ No newline at end of file
+} \ No newline at end of file
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ShaderGroupAccessor.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ShaderGroupAccessor.java
index 588da19..2ec0024 100644
--- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ShaderGroupAccessor.java
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/ShaderGroupAccessor.java
@@ -1,4 +1,3 @@
-//#if MC==10809
package cc.polyfrost.oneconfig.internal.mixin;
import net.minecraft.client.shader.Shader;
@@ -12,5 +11,4 @@ import java.util.List;
public interface ShaderGroupAccessor {
@Accessor("listShaders")
List<Shader> getListShaders();
-}
-//#endif \ No newline at end of file
+} \ 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 6b474ab..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,4 +1,3 @@
-//#if MC==10809
package cc.polyfrost.oneconfig.internal.mixin;
import gg.essential.vigilance.Vigilant;
@@ -6,5 +5,4 @@ import org.spongepowered.asm.mixin.Mixin;
@Mixin(Vigilant.class)
public class VigilantMixin {
-}
-//#endif \ No newline at end of file
+} \ No newline at end of file
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java
new file mode 100644
index 0000000..0063d1b
--- /dev/null
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java
@@ -0,0 +1,140 @@
+package cc.polyfrost.oneconfig.internal.plugin;
+
+import cc.polyfrost.oneconfig.platform.Platform;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
+import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+public class OneConfigMixinPlugin implements IMixinConfigPlugin {
+ private static boolean isVigilance = false;
+
+ @Override
+ public void onLoad(String mixinPackage) {
+ try {
+ Class.forName("gg.essential.vigilance.Vigilant");
+ isVigilance = true;
+ } catch (Exception e) {
+ isVigilance = false;
+ }
+ }
+
+ @Override
+ public String getRefMapperConfig() {
+ return null;
+ }
+
+ @Override
+ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
+ return !targetClassName.contains("vigilance") || isVigilance;
+ }
+
+ @Override
+ public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
+
+ }
+
+ @Override
+ public List<String> getMixins() {
+ if (Platform.getInstance().getMinecraftVersion() >= 11600) {
+ ArrayList<String> mixins = new ArrayList<>();
+ mixins.add("ClientModLoaderMixin");
+ mixins.add("KeyboardListenerMixin");
+ mixins.add("MouseHelperAccessor");
+ mixins.add("MouseHelperMixin");
+ mixins.add("TimeTrackerMixin");
+ return mixins;
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void preApply(String targetClassName, org.spongepowered.asm.lib.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
+
+ }
+
+ @Override
+ public void postApply(String targetClassName, org.spongepowered.asm.lib.tree.ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
+ if (mixinClassName.equals("cc.polyfrost.oneconfig.internal.mixin.VigilantMixin")) {
+ transform(targetClass);
+ }
+ }
+
+ /**
+ * If anything here is changed, edit the corresponding method in OneConfigMixinPlugin!
+ */
+ private void transform(org.spongepowered.asm.lib.tree.ClassNode node) {
+ if (!node.interfaces.contains("cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilantAccessor")) {
+ node.fields.add(new org.spongepowered.asm.lib.tree.FieldNode(Opcodes.ACC_PUBLIC, "oneconfig$config", "Lcc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig;", null, null));
+ node.fields.add(new org.spongepowered.asm.lib.tree.FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL, "oneconfig$file", Type.getDescriptor(File.class), null, null));
+
+ node.interfaces.add("cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilantAccessor");
+ org.spongepowered.asm.lib.tree.MethodNode methodNode = new org.spongepowered.asm.lib.tree.MethodNode(Opcodes.ACC_PUBLIC, "getPropertyCollector", "()Lgg/essential/vigilance/data/PropertyCollector;", null, null);
+ org.spongepowered.asm.lib.tree.LabelNode labelNode = new org.spongepowered.asm.lib.tree.LabelNode();
+ methodNode.instructions.add(labelNode);
+ methodNode.instructions.add(new org.spongepowered.asm.lib.tree.LineNumberNode(421421, labelNode));
+ methodNode.instructions.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ methodNode.instructions.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "propertyCollector", "Lgg/essential/vigilance/data/PropertyCollector;"));
+ methodNode.instructions.add(new org.spongepowered.asm.lib.tree.InsnNode(Opcodes.ARETURN));
+ node.methods.add(methodNode);
+
+ org.spongepowered.asm.lib.tree.MethodNode methodNode2 = new org.spongepowered.asm.lib.tree.MethodNode(Opcodes.ACC_PUBLIC, "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", null, null);
+ org.spongepowered.asm.lib.tree.LabelNode labelNode2 = new org.spongepowered.asm.lib.tree.LabelNode();
+ org.spongepowered.asm.lib.tree.LabelNode labelNode3 = new org.spongepowered.asm.lib.tree.LabelNode();
+ org.spongepowered.asm.lib.tree.LabelNode labelNode4 = new org.spongepowered.asm.lib.tree.LabelNode();
+ methodNode2.instructions.add(labelNode2);
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.LineNumberNode(15636436, labelNode2));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", "Lcc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig;"));
+
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.JumpInsnNode(Opcodes.IFNULL, labelNode4));
+
+ methodNode2.instructions.add(labelNode3);
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.LineNumberNode(15636437, labelNode3));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", "Lcc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig;"));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 1));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 2));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.MethodInsnNode(Opcodes.INVOKEVIRTUAL, "cc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig", "addDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false));
+
+ methodNode2.instructions.add(labelNode4);
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.LineNumberNode(15636438, labelNode4));
+ methodNode2.instructions.add(new org.spongepowered.asm.lib.tree.InsnNode(Opcodes.RETURN));
+ node.methods.add(methodNode2);
+
+ for (org.spongepowered.asm.lib.tree.MethodNode method : node.methods) {
+ if (method.name.equals("initialize")) {
+ org.spongepowered.asm.lib.tree.InsnList list = new org.spongepowered.asm.lib.tree.InsnList();
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class)));
+ list.add(new org.spongepowered.asm.lib.tree.MethodInsnNode(Opcodes.INVOKESTATIC, "cc/polyfrost/oneconfig/internal/plugin/hooks/VigilantHook", "returnNewConfig", "(Lgg/essential/vigilance/Vigilant;Ljava/io/File;)Lcc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig;", false));
+ list.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", "Lcc/polyfrost/oneconfig/config/compatibility/vigilance/VigilanceConfig;"));
+ method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
+ } else if (method.name.equals("addDependency") && method.desc.equals("(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V")) {
+ org.spongepowered.asm.lib.tree.InsnList list = new org.spongepowered.asm.lib.tree.InsnList();
+
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 1));
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 2));
+ list.add(new org.spongepowered.asm.lib.tree.MethodInsnNode(Opcodes.INVOKEVIRTUAL, "gg/essential/vigilance/Vigilant", "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false));
+
+ method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
+ } else if (method.name.equals("<init>") && method.desc.equals("(Ljava/io/File;Ljava/lang/String;Lgg/essential/vigilance/data/PropertyCollector;Lgg/essential/vigilance/data/SortingBehavior;)V")) {
+ org.spongepowered.asm.lib.tree.InsnList list = new org.spongepowered.asm.lib.tree.InsnList();
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 0));
+ list.add(new org.spongepowered.asm.lib.tree.VarInsnNode(Opcodes.ALOAD, 1));
+ list.add(new org.spongepowered.asm.lib.tree.FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class)));
+ method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
+ }
+ }
+ }
+ }
+}
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ClassTransformer.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ClassTransformer.java
index 52256ca..bbd47ac 100644
--- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ClassTransformer.java
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/ClassTransformer.java
@@ -1,3 +1,4 @@
+//#if MC<=11202
package cc.polyfrost.oneconfig.internal.plugin.asm;
import cc.polyfrost.oneconfig.internal.plugin.asm.tweakers.NanoVGGLConfigTransformer;
@@ -39,7 +40,6 @@ public class ClassTransformer implements IClassTransformer {
transformerMap.put(cls, transformer);
}
}
-
@Override
public byte[] transform(String name, String transformedName, byte[] bytes) {
if (bytes == null) return null;
@@ -99,4 +99,5 @@ public class ClassTransformer implements IClassTransformer {
return cw.toByteArray();
}
-} \ No newline at end of file
+}
+//#endif \ No newline at end of file
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/OneConfigTweaker.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/OneConfigTweaker.java
index d302b9d..b1f3eb2 100644
--- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/OneConfigTweaker.java
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/asm/OneConfigTweaker.java
@@ -1,3 +1,4 @@
+//#if MC<=11202
package cc.polyfrost.oneconfig.internal.plugin.asm;
import cc.polyfrost.oneconfig.internal.init.OneConfigInit;
@@ -114,4 +115,5 @@ public class OneConfigTweaker implements ITweaker {
public String[] getLaunchArguments() {
return new String[0];
}
-} \ No newline at end of file
+}
+//#endif \ No newline at end of file
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java
index 3ee962b..b53b357 100644
--- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java
@@ -1,10 +1,9 @@
package cc.polyfrost.oneconfig.platform.impl;
+import cc.polyfrost.oneconfig.libs.universal.UGraphics;
import cc.polyfrost.oneconfig.libs.universal.UMatrixStack;
import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
import cc.polyfrost.oneconfig.platform.GLPlatform;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
@@ -33,23 +32,23 @@ public class GLPlatformImpl implements GLPlatform {
float j = (float)(color & 0xFF) / 255.0F;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRenderer = tessellator.getWorldRenderer();
- GlStateManager.enableBlend();
- GlStateManager.disableTexture2D();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.color(g, h, j, f);
+ UGraphics.enableBlend();
+ UGraphics.disableTexture2D();
+ UGraphics.tryBlendFuncSeparate(770, 771, 1, 0);
+ UGraphics.color4f(g, h, j, f);
worldRenderer.begin(7, DefaultVertexFormats.POSITION);
worldRenderer.pos(x, y2, 0.0).endVertex();
worldRenderer.pos(x2, y2, 0.0).endVertex();
worldRenderer.pos(x2, y, 0.0).endVertex();
worldRenderer.pos(x, y, 0.0).endVertex();
tessellator.draw();
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
+ UGraphics.enableTexture2D();
+ UGraphics.disableBlend();
}
@Override
public void enableStencil() {
- Framebuffer framebuffer = Minecraft.getMinecraft().getFramebuffer();
+ Framebuffer framebuffer = UMinecraft.getMinecraft().getFramebuffer();
if (!framebuffer.isStencilEnabled()) {
framebuffer.enableStencil();
}
@@ -57,7 +56,13 @@ public class GLPlatformImpl implements GLPlatform {
@Override
public float drawText(UMatrixStack matrixStack, String text, float x, float y, int color, boolean shadow) {
+ //#if MC<=11202
return UMinecraft.getFontRenderer().drawString(text, x, y, color, shadow);
+ //#else
+ //$$ if(shadow) {
+ //$$ return UMinecraft.getFontRenderer().drawStringWithShadow(matrixStack.toMC(), text, x, y, color);
+ //$$ } else return UMinecraft.getFontRenderer().drawString(matrixStack.toMC(), text, x, y, color);
+ //#endif
}
@Override
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/LoaderPlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/LoaderPlatformImpl.java
index 01269cd..c984ac3 100644
--- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/LoaderPlatformImpl.java
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/LoaderPlatformImpl.java
@@ -1,6 +1,9 @@
package cc.polyfrost.oneconfig.platform.impl;
import cc.polyfrost.oneconfig.platform.LoaderPlatform;
+//#if MC>=11600
+//$$ import net.minecraftforge.fml.ModList;
+//#endif
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
@@ -8,7 +11,11 @@ import net.minecraftforge.fml.common.ModContainer;
public class LoaderPlatformImpl implements LoaderPlatform {
@Override
public boolean isModLoaded(String id) {
+ //#if MC>=11600
+ //$$ return ModList.get().isLoaded(id);
+ //#else
return Loader.isModLoaded(id);
+ //#endif
}
@Override
@@ -19,8 +26,11 @@ public class LoaderPlatformImpl implements LoaderPlatform {
@Override
public ActiveMod getActiveModContainer() {
ModContainer container = Loader.instance().activeModContainer();
- if (container == null)
- return null;
+ if (container == null) return null;
+ //#if MC==11202
return new ActiveMod(container.getName(), container.getModId(), container.getVersion());
+ //#else
+ //$$ return new ActiveMod(container.getModInfo().getDisplayName(), container.getModId(), container.getModInfo().getVersion().getQualifier());
+ //#endif
}
}
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/MousePlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/MousePlatformImpl.java
index 1276000..e368a91 100644
--- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/MousePlatformImpl.java
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/MousePlatformImpl.java
@@ -1,53 +1,84 @@
package cc.polyfrost.oneconfig.platform.impl;
import cc.polyfrost.oneconfig.platform.MousePlatform;
+//#if MC>=11600
+//$$ import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
+//$$ import cc.polyfrost.oneconfig.internal.mixin.MouseHelperAccessor;
+//$$ import org.lwjgl.glfw.GLFW;
+//#else
import org.lwjgl.input.Mouse;
+//#endif
@SuppressWarnings("unused")
public class MousePlatformImpl implements MousePlatform {
+ //#if MC>11600
+ //$$ private double prevScroll = 0;
+ //#endif
+
@Override
- public int getMouseX() {
+ public double getMouseX() {
+ //#if MC>=11600
+ //$$ return UMinecraft.getMinecraft().mouseHelper.getMouseX();
+ //#else
return Mouse.getX();
+ //#endif
}
@Override
- public int getMouseY() {
+ public double getMouseY() {
+ //#if MC>=11600
+ //$$ return UMinecraft.getMinecraft().mouseHelper.getMouseY();
+ //#else
return Mouse.getY();
+ //#endif
}
@Override
- public int getDWheel() {
+ public double getDWheel() {
+ //#if MC>=11600
+ //$$ double scrollDelta = ((MouseHelperAccessor) UMinecraft.getMinecraft().mouseHelper).getAccumulatedScrollDelta();
+ //$$ double amount = scrollDelta - prevScroll;
+ //$$ prevScroll = scrollDelta;
+ //$$ return amount;
+ //#else
return Mouse.getDWheel();
+ //#endif
}
@Override
- public int getMouseDX() {
+ public double getMouseDX() {
+ //#if MC>=11600
+ //$$ return UMinecraft.getMinecraft().mouseHelper.getXVelocity();
+ //#else
return Mouse.getDX();
+ //#endif
}
@Override
- public int getMouseDY() {
+ public double getMouseDY() {
+ //#if MC>=11600
+ //$$ return UMinecraft.getMinecraft().mouseHelper.getYVelocity();
+ //#else
return Mouse.getDY();
+ //#endif
}
@Override
- public boolean next() {
- return Mouse.next();
- }
-
- @Override
- public boolean getEventButtonState() {
- return Mouse.getEventButtonState();
- }
-
- @Override
- public int getEventButton() {
- return Mouse.getEventButton();
+ public int getButtonState(int button) {
+ //#if MC>=11600
+ //$$ return GLFW.glfwGetMouseButton(UMinecraft.getMinecraft().getMainWindow().getHandle(), button);
+ //#else
+ return Mouse.isButtonDown(button) ? 1 : 0;
+ //#endif
}
@Override
public boolean isButtonDown(int button) {
+ //#if MC>=11600
+ //$$ return GLFW.glfwGetMouseButton(UMinecraft.getMinecraft().getMainWindow().getHandle(), button) == GLFW.GLFW_PRESS;
+ //#else
return Mouse.isButtonDown(button);
+ //#endif
}
}
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/PlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/PlatformImpl.java
index 7ad639c..91edc53 100644
--- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/PlatformImpl.java
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/PlatformImpl.java
@@ -9,4 +9,33 @@ public class PlatformImpl implements Platform {
public boolean isCallingFromMinecraftThread() {
return Minecraft.getMinecraft().isCallingFromMinecraftThread();
}
+
+ @Override
+ public int getMinecraftVersion() {
+ //#if MC>=11900
+ //$$ return 11900;
+ //#elseif MC>=11800
+ //$$ return 11800;
+ //#elseif MC>=11700
+ //$$ return 11700;
+ //#elseif MC>=11600
+ //$$ return 11600;
+ //#elseif MC>=11500
+ //$$ return 11500;
+ //#elseif MC>=11400
+ //$$ return 11400;
+ //#elseif MC>=11300
+ //$$ return 11300;
+ //#elseif MC>=11200
+ //$$ return 11200;
+ //#elseif MC>=11100
+ //$$ return 11100;
+ //#elseif MC>=11000
+ //$$ return 11000;
+ //#elseif MC>=10900
+ //$$ return 10900;
+ //#else
+ return 10800;
+ //#endif
+ }
}
diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMod_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMod_Test.java
index ab7587e..0d2fb87 100644
--- a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMod_Test.java
+++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMod_Test.java
@@ -1,14 +1,20 @@
package cc.polyfrost.oneconfig.test;
-import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.common.event.FMLInitializationEvent;
+import cc.polyfrost.oneconfig.events.EventManager;
+import cc.polyfrost.oneconfig.events.event.InitializationEvent;
+import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
+//#if MC<=11202
@net.minecraftforge.fml.common.Mod(modid = "oneconfig-test-mod", name = "Test Mod", version = "0")
+//#endif
public class TestMod_Test {
private TestConfig_Test config;
+ public TestMod_Test() {
+ EventManager.INSTANCE.register(this);
+ }
- @Mod.EventHandler
- public void init(FMLInitializationEvent event) {
+ @Subscribe
+ public void init(InitializationEvent e) {
config = new TestConfig_Test();
}
} \ 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 76dab84..a4cd9ae 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
@@ -1,11 +1,10 @@
+//#if MC>=11202
package cc.polyfrost.oneconfig.utils.commands;
import cc.polyfrost.oneconfig.libs.universal.ChatColor;
import cc.polyfrost.oneconfig.libs.universal.UChat;
import cc.polyfrost.oneconfig.utils.commands.annotations.Command;
import cc.polyfrost.oneconfig.utils.commands.annotations.Greedy;
-import cc.polyfrost.oneconfig.utils.commands.annotations.Name;
-import cc.polyfrost.oneconfig.utils.commands.annotations.SubCommand;
import cc.polyfrost.oneconfig.utils.commands.arguments.ArgumentParser;
import cc.polyfrost.oneconfig.utils.commands.arguments.Arguments;
import net.minecraft.command.CommandBase;
@@ -22,11 +21,13 @@ import java.lang.reflect.Parameter;
import java.util.*;
import static cc.polyfrost.oneconfig.utils.commands.CommandManager.*;
+import static cc.polyfrost.oneconfig.utils.commands.CommandManager.METHOD_RUN_ERROR;
-public class PlatformCommandManagerImpl implements PlatformCommandManager {
+public class PlatformCommandManagerImpl extends PlatformCommandManager {
@Override
public void createCommand(CommandManager.InternalCommand root, Command annotation) {
+ //#if MC<=11202
ClientCommandHandler.instance.registerCommand(new CommandBase() {
@Override
public String getCommandName() {
@@ -46,7 +47,65 @@ public class PlatformCommandManagerImpl implements PlatformCommandManager {
//$$ execute(net.minecraft.server.MinecraftServer server, ICommandSender sender, String[] args)
//#endif
{
- handleCommand(root, annotation, args);
+ if (args.length == 0) {
+ if (!root.invokers.isEmpty()) {
+ try {
+ root.invokers.get(0).method.invoke(null);
+ } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException |
+ ExceptionInInitializerError e) {
+ e.printStackTrace();
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR);
+ }
+ }
+ } else {
+ if (annotation.helpCommand() && args[0].equalsIgnoreCase("help")) {
+ UChat.chat(sendHelpCommand(root));
+ } else {
+ List<CommandManager.InternalCommand.InternalCommandInvoker> commands = new ArrayList<>();
+ int depth = 0;
+ for (CommandManager.InternalCommand command : root.children) {
+ int newDepth = loopThroughCommands(commands, 0, command, args);
+ if (newDepth != -1) {
+ depth = newDepth;
+ break;
+ }
+ }
+ if (commands.isEmpty()) {
+ if (depth == -2) {
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + TOO_MANY_PARAMETERS.replace("@ROOT_COMMAND@", annotation.value()));
+ } else {
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + NOT_FOUND_TEXT.replace("@ROOT_COMMAND@", annotation.value()));
+ }
+ } else {
+ List<CommandManager.CustomError> errors = new ArrayList<>();
+ for (CommandManager.InternalCommand.InternalCommandInvoker invoker : commands) {
+ try {
+ List<Object> params = getParametersForInvoker(invoker, depth, args);
+ if (params.size() == 1) {
+ Object first = params.get(0);
+ if (first instanceof CommandManager.CustomError) {
+ errors.add((CommandManager.CustomError) first);
+ continue;
+ }
+ }
+ invoker.method.invoke(null, params.toArray());
+ return;
+ } catch (Exception e) {
+ e.printStackTrace();
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR);
+ return;
+ }
+ }
+ //noinspection ConstantConditions
+ if (!errors.isEmpty()) {
+ UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + "Multiple errors occurred:");
+ for (CommandManager.CustomError error : errors) {
+ UChat.chat(" " + ChatColor.RED + ChatColor.BOLD + error.message);
+ }
+ }
+ }
+ }
+ }
}
@Override
@@ -62,157 +121,93 @@ public class PlatformCommandManagerImpl implements PlatformCommandManager {
//$$ getTabCompletions(net.minecraft.server.MinecraftServer server, ICommandSender sender, String[] args, BlockPos targetPos)
//#endif
{
- return handleTabCompletion(root, annotation, args);
- }
- });
- }
-
- private void handleCommand(CommandManager.InternalCommand root, Command annotation, String[] args) {
- if (args.length == 0) {
- if (!root.invokers.isEmpty()) {
try {
- root.invokers.get(0).method.invoke(null);
- } catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException |
- ExceptionInInitializerError e) {
- e.printStackTrace();
- UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR);
- }
- }
- } else {
- if (annotation.helpCommand() && args[0].equalsIgnoreCase("help")) {
- UChat.chat(sendHelpCommand(root));
- } else {
- List<CommandManager.InternalCommand.InternalCommandInvoker> commands = new ArrayList<>();
- int depth = 0;
- for (CommandManager.InternalCommand command : root.children) {
- int newDepth = loopThroughCommands(commands, 0, command, args);
- if (newDepth != -1) {
- depth = newDepth;
- break;
- }
- }
- if (commands.isEmpty()) {
- if (depth == -2) {
- UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + TOO_MANY_PARAMETERS.replace("@ROOT_COMMAND@", annotation.value()));
- } else {
- UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + NOT_FOUND_TEXT.replace("@ROOT_COMMAND@", annotation.value()));
+ Set<Pair<InternalCommand.InternalCommandInvoker, Integer>> commands = new HashSet<>();
+ for (CommandManager.InternalCommand command : root.children) {
+ loopThroughCommandsTab(commands, 0, command, args);
}
- } else {
- List<CommandManager.CustomError> errors = new ArrayList<>();
- for (CommandManager.InternalCommand.InternalCommandInvoker invoker : commands) {
- try {
- List<Object> params = getParametersForInvoker(invoker, depth, args);
- if (params.size() == 1) {
- Object first = params.get(0);
- if (first instanceof CommandManager.CustomError) {
- errors.add((CommandManager.CustomError) first);
- continue;
+ if (!commands.isEmpty() || annotation.helpCommand()) {
+ List<Triple<InternalCommand.InternalCommandInvoker, Integer, Integer>> validCommands = new ArrayList<>(); // command, depth, and all processed params
+ for (Pair<CommandManager.InternalCommand.InternalCommandInvoker, Integer> pair : commands) {
+ CommandManager.InternalCommand.InternalCommandInvoker invoker = pair.getLeft();
+ int depth = pair.getRight();
+ int currentParam = 0;
+ boolean failed = false;
+ while (args.length - depth > 1) {
+ Parameter param = invoker.method.getParameters()[currentParam];
+ if (param.isAnnotationPresent(Greedy.class) && currentParam + 1 != invoker.parameterTypes.length) {
+ failed = true;
+ break;
+ }
+ ArgumentParser<?> parser = INSTANCE.parsers.get(param.getType());
+ if (parser == null) {
+ failed = true;
+ break;
+ }
+ try {
+ Arguments arguments = new Arguments(Arrays.copyOfRange(args, depth, args.length), param.isAnnotationPresent(Greedy.class));
+ if (parser.parse(arguments) != null) {
+ depth += arguments.getPosition();
+ currentParam++;
+ } else {
+ failed = true;
+ break;
+ }
+ } catch (Exception e) {
+ failed = true;
+ break;
}
}
- invoker.method.invoke(null, params.toArray());
- return;
- } catch (Exception e) {
- e.printStackTrace();
- UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + METHOD_RUN_ERROR);
- return;
- }
- }
- //noinspection ConstantConditions
- if (!errors.isEmpty()) {
- UChat.chat(ChatColor.RED.toString() + ChatColor.BOLD + "Multiple errors occurred:");
- for (CommandManager.CustomError error : errors) {
- UChat.chat(" " + ChatColor.RED + ChatColor.BOLD + error.message);
+ if (!failed) {
+ validCommands.add(new ImmutableTriple<>(pair.getLeft(), depth, currentParam));
+ }
}
- }
- }
- }
- }
- }
+ if (!validCommands.isEmpty() || annotation.helpCommand()) {
+ Set<String> completions = new HashSet<>();
+ for (Triple<CommandManager.InternalCommand.InternalCommandInvoker, Integer, Integer> valid : validCommands) {
+ if (valid.getMiddle() == args.length) {
+ completions.add(valid.getLeft().name);
+ completions.addAll(Arrays.asList(valid.getLeft().aliases));
+ continue;
+ }
+ if (valid.getRight() + 1 > valid.getLeft().parameterTypes.length) continue;
+ Parameter param = valid.getLeft().method.getParameters()[valid.getRight()];
+ if (param.isAnnotationPresent(Greedy.class) && valid.getRight() + 1 != valid.getLeft().parameterTypes.length) {
+ continue;
+ }
+ ArgumentParser<?> parser = INSTANCE.parsers.get(param.getType());
+ if (parser == null) {
+ continue;
+ }
+ try {
+ Arguments arguments = new Arguments(Arrays.copyOfRange(args, valid.getMiddle(), args.length), param.isAnnotationPresent(Greedy.class));
+ List<String> possibleCompletions = parser.complete(arguments, param);
+ if (possibleCompletions != null) {
+ completions.addAll(possibleCompletions);
+ }
+ } catch (Exception ignored) {
- private List<String> handleTabCompletion(CommandManager.InternalCommand root, Command annotation, String[] args) {
- try {
- Set<Pair<CommandManager.InternalCommand.InternalCommandInvoker, Integer>> commands = new HashSet<>();
- for (CommandManager.InternalCommand command : root.children) {
- loopThroughCommandsTab(commands, 0, command, args);
- }
- if (!commands.isEmpty() || annotation.helpCommand()) {
- List<Triple<CommandManager.InternalCommand.InternalCommandInvoker, Integer, Integer>> validCommands = new ArrayList<>(); // command, depth, and all processed params
- for (Pair<CommandManager.InternalCommand.InternalCommandInvoker, Integer> pair : commands) {
- CommandManager.InternalCommand.InternalCommandInvoker invoker = pair.getLeft();
- int depth = pair.getRight();
- int currentParam = 0;
- boolean failed = false;
- while (args.length - depth > 1) {
- Parameter param = invoker.method.getParameters()[currentParam];
- if (param.isAnnotationPresent(Greedy.class) && currentParam + 1 != invoker.parameterTypes.length) {
- failed = true;
- break;
- }
- ArgumentParser<?> parser = INSTANCE.parsers.get(param.getType());
- if (parser == null) {
- failed = true;
- break;
- }
- try {
- Arguments arguments = new Arguments(Arrays.copyOfRange(args, depth, args.length), param.isAnnotationPresent(Greedy.class));
- if (parser.parse(arguments) != null) {
- depth += arguments.getPosition();
- currentParam++;
- } else {
- failed = true;
- break;
+ }
}
- } catch (Exception e) {
- failed = true;
- break;
- }
- }
- if (!failed) {
- validCommands.add(new ImmutableTriple<>(pair.getLeft(), depth, currentParam));
- }
- }
- if (!validCommands.isEmpty() || annotation.helpCommand()) {
- Set<String> completions = new HashSet<>();
- for (Triple<CommandManager.InternalCommand.InternalCommandInvoker, Integer, Integer> valid : validCommands) {
- if (valid.getMiddle() == args.length) {
- completions.add(valid.getLeft().name);
- completions.addAll(Arrays.asList(valid.getLeft().aliases));
- continue;
- }
- if (valid.getRight() + 1 > valid.getLeft().parameterTypes.length) continue;
- Parameter param = valid.getLeft().method.getParameters()[valid.getRight()];
- if (param.isAnnotationPresent(Greedy.class) && valid.getRight() + 1 != valid.getLeft().parameterTypes.length) {
- continue;
- }
- ArgumentParser<?> parser = INSTANCE.parsers.get(param.getType());
- if (parser == null) {
- continue;
- }
- try {
- Arguments arguments = new Arguments(Arrays.copyOfRange(args, valid.getMiddle(), args.length), param.isAnnotationPresent(Greedy.class));
- List<String> possibleCompletions = parser.complete(arguments, param);
- if (possibleCompletions != null) {
- completions.addAll(possibleCompletions);
+ if (args.length == 1 && annotation.helpCommand()) {
+ if ("help".startsWith(args[0].toLowerCase(Locale.ENGLISH))) {
+ completions.add("help");
+ }
}
- } catch (Exception ignored) {
-
+ return new ArrayList<>(completions);
}
}
- if (args.length == 1 && annotation.helpCommand()) {
- if ("help".startsWith(args[0].toLowerCase(Locale.ENGLISH))) {
- completions.add("help");
- }
- }
- return new ArrayList<>(completions);
+ } catch (Exception ignored) {
+
}
+ return null;
}
- } catch (Exception ignored) {
-
- }
- return null;
+ });
+ //#else
+ //#endif
}
- private List<Object> getParametersForInvoker(CommandManager.InternalCommand.InternalCommandInvoker invoker, int depth, String[] args) {
+ protected List<Object> getParametersForInvoker(CommandManager.InternalCommand.InternalCommandInvoker invoker, int depth, String[] args) {
List<Object> parameters = new ArrayList<>();
int processed = depth;
int currentParam = 0;
@@ -246,7 +241,7 @@ public class PlatformCommandManagerImpl implements PlatformCommandManager {
return parameters;
}
- private int loopThroughCommands(List<CommandManager.InternalCommand.InternalCommandInvoker> commands, int depth, CommandManager.InternalCommand command, String[] args) {
+ protected int loopThroughCommands(List<CommandManager.InternalCommand.InternalCommandInvoker> commands, int depth, CommandManager.InternalCommand command, String[] args) {
int nextDepth = depth + 1;
boolean thatOneSpecialError = false;
if (command.isValid(args[depth], false)) {
@@ -276,7 +271,7 @@ public class PlatformCommandManagerImpl implements PlatformCommandManager {
return thatOneSpecialError ? -2 : -1;
}
- private void loopThroughCommandsTab(Set<Pair<CommandManager.InternalCommand.InternalCommandInvoker, Integer>> commands, int depth, CommandManager.InternalCommand command, String[] args) {
+ protected void loopThroughCommandsTab(Set<Pair<CommandManager.InternalCommand.InternalCommandInvoker, Integer>> commands, int depth, CommandManager.InternalCommand command, String[] args) {
int nextDepth = depth + 1;
if (command.isValid(args[depth], args.length == nextDepth)) {
if (args.length != nextDepth) {
@@ -291,52 +286,5 @@ public class PlatformCommandManagerImpl implements PlatformCommandManager {
}
}
}
-
- //TODO: someone make the help command actually look nice lmao
- private String sendHelpCommand(CommandManager.InternalCommand root) {
- StringBuilder builder = new StringBuilder();
- builder.append(ChatColor.GOLD).append("Help for ").append(ChatColor.BOLD).append(root.name).append(ChatColor.RESET).append(ChatColor.GOLD).append(":\n");
- if (!root.description.isEmpty()) {
- builder.append("\n").append(ChatColor.GOLD).append("Description: ").append(ChatColor.BOLD).append(root.description);
- }
- for (CommandManager.InternalCommand command : root.children) {
- runThroughCommandsHelp(root.name, command, builder);
- }
- builder.append("\n").append(ChatColor.GOLD).append("Aliases: ").append(ChatColor.BOLD);
- int index = 0;
- for (String alias : root.aliases) {
- ++index;
- builder.append(alias).append(index < root.aliases.length ? ", " : "");
- }
- builder.append("\n");
- return builder.toString();
- }
-
- private void runThroughCommandsHelp(String append, CommandManager.InternalCommand command, StringBuilder builder) {
- if (!command.invokers.isEmpty()) {
- Class<?> declaringClass = command.invokers.get(0).method.getDeclaringClass();
- if (declaringClass.isAnnotationPresent(SubCommand.class)) {
- String description = declaringClass.getAnnotation(SubCommand.class).description();
- if (!description.isEmpty()) {
- builder.append("\n").append(ChatColor.GOLD).append("Description: ").append(ChatColor.BOLD).append(description);
- }
- }
- }
- for (CommandManager.InternalCommand.InternalCommandInvoker invoker : command.invokers) {
- builder.append("\n").append(ChatColor.GOLD).append("/").append(append).append(" ").append(command.name);
- for (Parameter parameter : invoker.method.getParameters()) {
- String name = parameter.getName();
- if (parameter.isAnnotationPresent(Name.class)) {
- name = parameter.getAnnotation(Name.class).value();
- }
- builder.append(" <").append(name).append(">");
- }
- if (!command.description.trim().isEmpty()) {
- builder.append(": ").append(ChatColor.BOLD).append(command.description);
- }
- }
- for (CommandManager.InternalCommand subCommand : command.children) {
- runThroughCommandsHelp(append + " " + command.name, subCommand, builder);
- }
- }
-} \ No newline at end of file
+}
+//#endif \ No newline at end of file
diff --git a/versions/src/main/resources/META-INF/mods.toml b/versions/src/main/resources/META-INF/mods.toml
new file mode 100644
index 0000000..8050cf5
--- /dev/null
+++ b/versions/src/main/resources/META-INF/mods.toml
@@ -0,0 +1,30 @@
+modLoader="javafml"
+loaderVersion="[32,)"
+license="https://www.gnu.org/licenses/lgpl-3.0.en.html"
+[[mods]]
+modId="${id}"
+version="${version}"
+displayName="${name}"
+authors="Polyfrost"
+description="OneConfig"
+
+# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
+[[dependencies.oneconfig]] #optional
+# the modid of the dependency
+modId="forge" #mandatory
+# Does this dependency have to exist - if not, ordering below must be specified
+mandatory=true #mandatory
+# The version range of the dependency
+versionRange="[32,)" #mandatory
+# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
+ordering="NONE"
+# Side this dependency is applied on - BOTH, CLIENT or SERVER
+side="BOTH"
+# Here's another dependency
+[[dependencies.oneconfig]]
+modId="minecraft"
+mandatory=true
+# This version range declares a minimum of the current minecraft version up to but not including the next major version
+versionRange="[1.16,)"
+ordering="NONE"
+side="BOTH" \ No newline at end of file
diff --git a/versions/src/main/resources/pack.mcmeta b/versions/src/main/resources/pack.mcmeta
new file mode 100644
index 0000000..5d61962
--- /dev/null
+++ b/versions/src/main/resources/pack.mcmeta
@@ -0,0 +1,7 @@
+{
+ "pack": {
+ "description": "oneconfig resources",
+ "pack_format": 6,
+ "_comment": "A pack_format of 5 requires json lang files and some texture changes from 1.15. Note: we require v5 pack meta for all mods."
+ }
+}