Skip to content

Commit

Permalink
Update BytecodeTransformers
Browse files Browse the repository at this point in the history
  • Loading branch information
DrParadox7 committed Aug 31, 2022
1 parent 8bfe80c commit 2c8c603
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions src/main/java/am2/preloader/AM2PreloaderContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;

Expand Down Expand Up @@ -83,6 +84,11 @@ public String getSetupClass(){

@Override
public void injectData(Map<String, Object> data){
if ((data.get("coremodList").toString()).contains("DragonAPIASMHandler")){
LogHelper.info("Core: Located DragonAPI in list of coremods");
foundDragonAPI = true;
}

// This is very crude check for mods presence using filename.
// Some mods may refer to others in their name, so we'll to confirm those assumption with class presence check.
File loc = (File)data.get("mcLocation");
Expand All @@ -91,7 +97,14 @@ public void injectData(Map<String, Object> data){
isDevEnvironment = !(Boolean)data.get("runtimeDeobfuscationEnabled");

File mcFolder = new File(loc.getAbsolutePath() + File.separatorChar + "mods");
File[] subfiles = mcFolder.listFiles();
File mcVersionFolder = new File(mcFolder.getAbsolutePath() + File.separatorChar + "1.7.10");
ArrayList<File> subfiles = new ArrayList<>();
if (mcFolder.listFiles() != null){
subfiles = new ArrayList<>(Arrays.asList(mcFolder.listFiles()));
if (mcVersionFolder.listFiles() != null){
subfiles.addAll(Arrays.asList(mcVersionFolder.listFiles()));
}
}
for (File file : subfiles){
String name = file.getName();
if (name != null) {
Expand Down Expand Up @@ -140,4 +153,4 @@ public static boolean isOptiFinePresent(){
}
return foundOptiFine;
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/am2/preloader/BytecodeTransformers.java
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ private byte[] alterS1EPacketRemoveEntityEffect(byte[] bytes, boolean is_obfusca
InsnList new_if = new InsnList();
new_if.add(new VarInsnNode(Opcodes.ALOAD, 1));
new_if.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, method1_searchinstruction_owner.getVal(is_obfuscated), method1_checkinstruction_function, method1_checkinstruction_desc, false));
new_if.add(new IntInsnNode(Opcodes.BIPUSH, 8));
new_if.add(new IntInsnNode(Opcodes.BIPUSH, Integer.BYTES));
LabelNode elseLabel = new LabelNode();
new_if.add(new JumpInsnNode(Opcodes.IF_ICMPNE, elseLabel));
new_if.add(new VarInsnNode(Opcodes.ALOAD, 0));
Expand Down Expand Up @@ -1380,4 +1380,4 @@ public String getVal(boolean is_obfuscated){
}
}
}
}
}

0 comments on commit 2c8c603

Please sign in to comment.