Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into master-ame
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/meteordevelopment/meteorclient/asm/Asm.java
#	src/main/java/meteordevelopment/meteorclient/mixin/MinecraftClientMixin.java
#	src/main/java/meteordevelopment/meteorclient/systems/modules/player/AutoTool.java
  • Loading branch information
JFronny committed Sep 15, 2023
2 parents c40f2b0 + 52595d0 commit e4c053c
Show file tree
Hide file tree
Showing 66 changed files with 1,849 additions and 920 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ dependencies {
modCompileOnly("maven.modrinth:lithium:${project.lithium_version}") { transitive = false }
modCompileOnly("maven.modrinth:iris:${project.iris_version}") { transitive = false }
//modCompileOnly("io.vram:canvas-fabric-mc119:1.0.+") { transitive = false } // TODO: 1.19.3
modCompileOnly("maven.modrinth:indium:${project.indium_version}") { transitive = false }

// Baritone (https://github.com/MeteorDevelopment/baritone)
modInclude "baritone:fabric:${project.minecraft_version}-SNAPSHOT"
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ netty_version=4.1.90.Final

# Mixin Extras (https://github.com/LlamaLad7/MixinExtras)
mixin_extras_version=0.2.0-beta.8

# Indium (https://github.com/comp500/Indium)
indium_version=1.0.25+mc1.20.1
5 changes: 5 additions & 0 deletions src/main/java/meteordevelopment/meteorclient/MixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class MixinPlugin implements IMixinConfigPlugin {
private static boolean isCanvasPresent;
private static boolean isLithiumPresent;
public static boolean isIrisPresent;
private static boolean isIndiumPresent;

@Override
public void onLoad(String mixinPackage) {
Expand All @@ -33,6 +34,7 @@ public void onLoad(String mixinPackage) {
isCanvasPresent = FabricLoader.getInstance().isModLoaded("canvas");
isLithiumPresent = FabricLoader.getInstance().isModLoaded("lithium");
isIrisPresent = FabricLoader.getInstance().isModLoaded("iris");
isIndiumPresent = FabricLoader.getInstance().isModLoaded("indium");

loaded = true;
}
Expand All @@ -59,6 +61,9 @@ else if (mixinClassName.startsWith(mixinPackage + ".canvas")) {
else if (mixinClassName.startsWith(mixinPackage + ".lithium")) {
return isLithiumPresent;
}
else if (mixinClassName.startsWith(mixinPackage + ".indium")) {
return isIndiumPresent;
}


return true;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/meteordevelopment/meteorclient/asm/Asm.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.asm.transformers.CanvasWorldRendererTransformer;
import meteordevelopment.meteorclient.asm.transformers.GameRendererTransformer;
import meteordevelopment.meteorclient.asm.transformers.PacketInflaterTransformer;
import net.fabricmc.loader.api.FabricLoader;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
Expand Down Expand Up @@ -38,6 +39,7 @@ public Asm() {

add(new GameRendererTransformer());
add(new CanvasWorldRendererTransformer());
add(new PacketInflaterTransformer());
}

private void add(AsmTransformer transformer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ protected MethodNode getMethod(ClassNode klass, MethodInfo methodInfo) {
return null;
}

protected static void error(String message) {
System.err.println(message);
throw new RuntimeException(message);
}

protected static String mapClassName(String name) {
return FabricLoader.getInstance().getMappingResolver().mapClassName("intermediary", name.replace('/', '.'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ public GameRendererTransformer() {
public void transform(ClassNode klass) {
// Modify GameRenderer.getFov()
MethodNode method = getMethod(klass, getFovMethod);
if (method == null) throw new RuntimeException("[Meteor Client] Could not find method GameRenderer.getFov()");
if (method == null) error("[Meteor Client] Could not find method GameRenderer.getFov()");

int injectionCount = 0;

//noinspection DataFlowIssue
for (AbstractInsnNode insn : method.instructions) {
if (insn instanceof LdcInsnNode in && in.cst instanceof Double && (double) in.cst == 90) {
InsnList insns = new InsnList();
Expand All @@ -52,7 +53,7 @@ else if (
}
}

if (injectionCount < 2) throw new RuntimeException("[Meteor Client] Failed to modify GameRenderer.getFov()");
if (injectionCount < 2) error("[Meteor Client] Failed to modify GameRenderer.getFov()");
}

private void generateEventCall(InsnList insns, AbstractInsnNode loadPreviousFov) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.asm.transformers;

import meteordevelopment.meteorclient.asm.AsmTransformer;
import meteordevelopment.meteorclient.asm.Descriptor;
import meteordevelopment.meteorclient.asm.MethodInfo;
import meteordevelopment.meteorclient.systems.modules.misc.AntiPacketKick;
import org.objectweb.asm.Label;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.*;

// Future compatibility
// Future uses @ModifyConstant which does not chain when multiple mods do it and mixins / mixinextra can't target throw
// statements. So using a custom ASM transformer we wrap the throw statement inside another if statement.
public class PacketInflaterTransformer extends AsmTransformer {
private final MethodInfo decodeMethod;

public PacketInflaterTransformer() {
super(mapClassName("net/minecraft/class_2532"));

decodeMethod = new MethodInfo("net/minecraft/class_2532", "decode", new Descriptor("Lio/netty/channel/ChannelHandlerContext;", "Lio/netty/buffer/ByteBuf;", "Ljava/util/List;", "V"), true);
}

@Override
public void transform(ClassNode klass) {
MethodNode method = getMethod(klass, decodeMethod);
if (method == null) error("[Meteor Client] Could not find method PacketInflater.decode()");

int newCount = 0;
LabelNode label = new LabelNode(new Label());

//noinspection DataFlowIssue
for (AbstractInsnNode insn : method.instructions) {
if (insn instanceof TypeInsnNode typeInsn && typeInsn.getOpcode() == Opcodes.NEW && typeInsn.desc.equals("io/netty/handler/codec/DecoderException")) {
newCount++;

if (newCount == 2) {
InsnList list = new InsnList();

list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "meteordevelopment/meteorclient/systems/modules/Modules", "get", "()Lmeteordevelopment/meteorclient/systems/modules/Modules;", false));
list.add(new LdcInsnNode(Type.getType(AntiPacketKick.class)));
list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "meteordevelopment/meteorclient/systems/modules/Modules", "isActive", "(Ljava/lang/Class;)Z", false));

list.add(new JumpInsnNode(Opcodes.IFNE, label));

method.instructions.insertBefore(insn, list);
}
}
else if (newCount == 2 && insn.getOpcode() == Opcodes.ATHROW) {
method.instructions.insert(insn, label);
return;
}
}

error("[Meteor Client] Failed to modify PacketInflater.decode()");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import static meteordevelopment.meteorclient.MeteorClient.mc;

public class ServerCommand extends Command {
private static final List<String> ANTICHEAT_LIST = Arrays.asList("nocheatplus", "negativity", "warden", "horizon", "illegalstack", "coreprotect", "exploitsx", "vulcan", "abc", "spartan", "kauri", "anticheatreloaded", "witherac", "godseye", "matrix", "wraith");
private static final List<String> ANTICHEAT_LIST = Arrays.asList("nocheatplus", "negativity", "warden", "horizon", "illegalstack", "coreprotect", "exploitsx", "vulcan", "abc", "spartan", "kauri", "anticheatreloaded", "witherac", "godseye", "matrix", "wraith", "antixrayheuristics");
private static final String completionStarts = "/:abcdefghijklmnopqrstuvwxyz0123456789-";
private int ticks = 0;
private boolean bukkitMode = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,43 @@

package meteordevelopment.meteorclient.mixin;

import com.mojang.authlib.GameProfile;
import meteordevelopment.meteorclient.mixininterface.IChatHudLine;
import net.minecraft.client.gui.hud.ChatHudLine;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;

@Mixin(value = { ChatHudLine.class, ChatHudLine.Visible.class })
@Mixin(value = ChatHudLine.class)
public class ChatHudLineMixin implements IChatHudLine {
@Shadow @Final private Text content;
@Unique private int id;
@Unique private GameProfile sender;

@Override
public int getId() {
public String meteor$getText() {
return content.getString();
}

@Override
public int meteor$getId() {
return id;
}

@Override
public void setId(int id) {
public void meteor$setId(int id) {
this.id = id;
}

@Override
public GameProfile meteor$getSender() {
return sender;
}

@Override
public void meteor$setSender(GameProfile profile) {
sender = profile;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.mixin;

import com.mojang.authlib.GameProfile;
import meteordevelopment.meteorclient.mixininterface.IChatHudLineVisible;
import net.minecraft.client.gui.hud.ChatHudLine;
import net.minecraft.text.OrderedText;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;

@Mixin(ChatHudLine.Visible.class)
public class ChatHudLineVisibleMixin implements IChatHudLineVisible {
@Shadow @Final private OrderedText content;
@Unique private int id;
@Unique private GameProfile sender;
@Unique private boolean startOfEntry;

@Override
public String meteor$getText() {
StringBuilder sb = new StringBuilder();

content.accept((index, style, codePoint) -> {
sb.appendCodePoint(codePoint);
return true;
});

return sb.toString();
}

@Override
public int meteor$getId() {
return id;
}

@Override
public void meteor$setId(int id) {
this.id = id;
}

@Override
public GameProfile meteor$getSender() {
return sender;
}

@Override
public void meteor$setSender(GameProfile profile) {
sender = profile;
}

@Override
public boolean meteor$isStartOfEntry() {
return startOfEntry;
}

@Override
public void meteor$setStartOfEntry(boolean start) {
startOfEntry = start;
}
}
Loading

0 comments on commit e4c053c

Please sign in to comment.