aboutsummaryrefslogtreecommitdiff
path: root/versions/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'versions/src/main')
-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
19 files changed, 474 insertions, 265 deletions
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."
+ }
+}