diff --git a/src/main/java/top/hendrixshen/tweakmyclient/compat/meteor/MeteorHelper.java b/src/main/java/top/hendrixshen/tweakmyclient/compat/meteor/MeteorHelper.java new file mode 100644 index 00000000..c4cf6df6 --- /dev/null +++ b/src/main/java/top/hendrixshen/tweakmyclient/compat/meteor/MeteorHelper.java @@ -0,0 +1,37 @@ +package top.hendrixshen.tweakmyclient.compat.meteor; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class MeteorHelper { + private static Method isNoSlowMethod; + private static Object noSlowInstance; + + static { + try { + Class meteorModules = Class.forName("meteordevelopment.meteorclient.systems.modules.Modules"); + Method getMeteorModulesMethod = meteorModules.getDeclaredMethod("get"); + getMeteorModulesMethod.setAccessible(true); + Object meteorModulesInstance = getMeteorModulesMethod.invoke(null); + Method getModuleMethod = meteorModules.getDeclaredMethod("get", Class.class); + Class noSlowClass = Class.forName("meteordevelopment.meteorclient.systems.modules.movement.NoSlow"); + getModuleMethod.setAccessible(true); + MeteorHelper.noSlowInstance = getModuleMethod.invoke(meteorModulesInstance, noSlowClass); + MeteorHelper.isNoSlowMethod = noSlowClass.getDeclaredMethod("items"); + MeteorHelper.isNoSlowMethod.setAccessible(true); + } catch (ClassNotFoundException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { + e.printStackTrace(); + } + } + + public static boolean isNoSlowdownHackEnable() { + if (MeteorHelper.noSlowInstance != null) { + try { + return (boolean) MeteorHelper.isNoSlowMethod.invoke(MeteorHelper.noSlowInstance); + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + return false; + } +} diff --git a/src/main/java/top/hendrixshen/tweakmyclient/compat/meteor/mixin/MixinLocalPlayer.java b/src/main/java/top/hendrixshen/tweakmyclient/compat/meteor/mixin/MixinLocalPlayer.java new file mode 100644 index 00000000..1b7c1103 --- /dev/null +++ b/src/main/java/top/hendrixshen/tweakmyclient/compat/meteor/mixin/MixinLocalPlayer.java @@ -0,0 +1,42 @@ +package top.hendrixshen.tweakmyclient.compat.meteor.mixin; + +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import top.hendrixshen.magiclib.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.dependency.annotation.Dependency; +import top.hendrixshen.tweakmyclient.compat.meteor.MeteorHelper; +import top.hendrixshen.tweakmyclient.compat.wurst.WurstHelper; +import top.hendrixshen.tweakmyclient.config.Configs; +import top.hendrixshen.tweakmyclient.util.mixin.MixinType; +import top.hendrixshen.tweakmyclient.util.mixin.annotation.MagicAttack; +import top.hendrixshen.tweakmyclient.util.mixin.annotation.MagicInterruption; + +@MagicInterruption(targets = "meteordevelopment.meteorclient.mixin.ClientPlayerEntityMixin") +@Dependencies(and = @Dependency(value = "meteor-client")) +@Mixin(value = LocalPlayer.class, priority = 1100) +public abstract class MixinLocalPlayer extends LivingEntity { + @Shadow + private boolean startedUsingItem; + + protected MixinLocalPlayer(EntityType entityType, Level level) { + super(entityType, level); + } + + @MagicAttack( + type = MixinType.REDIRECT, + name = "wurstIsUsingItem", + owner = "class_1309", + method = "method_6007", + desc = "()V" + ) + private boolean tmc$getUsingItemState(LocalPlayer instance) { + if (Configs.disableSlowdown || MeteorHelper.isNoSlowdownHackEnable()) { + return false; + } + return this.startedUsingItem; + } +} diff --git a/src/main/java/top/hendrixshen/tweakmyclient/mixin/disable/disableSlowdown/MixinLocalPlayer.java b/src/main/java/top/hendrixshen/tweakmyclient/mixin/disable/disableSlowdown/MixinLocalPlayer.java index beffa2bc..00eec4e2 100644 --- a/src/main/java/top/hendrixshen/tweakmyclient/mixin/disable/disableSlowdown/MixinLocalPlayer.java +++ b/src/main/java/top/hendrixshen/tweakmyclient/mixin/disable/disableSlowdown/MixinLocalPlayer.java @@ -12,7 +12,12 @@ import top.hendrixshen.magiclib.dependency.annotation.Dependency; import top.hendrixshen.tweakmyclient.config.Configs; -@Dependencies(not = @Dependency(value = "wurst")) +@Dependencies( + not = { + @Dependency(value = "meteor-client"), + @Dependency(value = "wurst") + } +) @Mixin(LocalPlayer.class) public abstract class MixinLocalPlayer extends LivingEntity { @Shadow diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2188686f..aa8fa293 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,6 +30,7 @@ }, "mixins": [ "${mod_id}.mixins.json", + "${mod_id}-compat-meteor.mixins.json", "${mod_id}-compat-wurst.mixins.json" ], "depends": { diff --git a/src/main/resources/tweakmyclient-compat-meteor.mixins.json b/src/main/resources/tweakmyclient-compat-meteor.mixins.json new file mode 100644 index 00000000..261b5ce0 --- /dev/null +++ b/src/main/resources/tweakmyclient-compat-meteor.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "top.hendrixshen.tweakmyclient.compat.meteor.mixin", + "plugin": "top.hendrixshen.tweakmyclient.compat.CompatMixinPlugin", + "compatibilityLevel": "JAVA_8", + "mixins": [ + ], + "client": [ + "MixinLocalPlayer" + ], + "injectors": { + "defaultRequire": 1 + } +}