Replace multidoj7 with dx1.16 (base multidoj16)

This commit is contained in:
khanhduytran0
2020-03-21 05:09:16 +07:00
parent 32b121cbd2
commit 6d194ae356
1796 changed files with 169 additions and 199 deletions

View File

@@ -3,8 +3,32 @@ import java.io.*;
public class LoggerJava
{
public static class LoggerDXPrintStream extends PrintStream {
private OnCharPrintListener mListener;
private StringBuilder mCurrText = new StringBuilder();
public LoggerDXPrintStream(OutputStream out, OnCharPrintListener listener)
{
super(out);
mListener = listener;
}
@Override
public void print(String s)
{
super.print(s);
if (mListener != null) mListener.onCharPrint(s);
}
@Override
public void println(String s)
{
super.println(s);
if (mListener != null) mListener.onCharPrint(s + "\n");
}
}
public static interface OnCharPrintListener {
public void onCharPrint(char c);
public void onCharPrint(String s);
}
public static class LoggerOutputStream extends FilterOutputStream
@@ -20,7 +44,7 @@ public class LoggerJava
public void write(final int charCode) throws IOException
{
super.write(charCode);
mListener.onCharPrint((char) charCode);
mListener.onCharPrint(Character.toString((char) charCode));
}
}

View File

@@ -461,16 +461,16 @@ public class MCLauncherActivity extends AppCompatActivity
final StringBuilder currentLog = new StringBuilder();
LoggerJava.LoggerOutputStream logOut = new LoggerJava.LoggerOutputStream(System.out, new LoggerJava.OnCharPrintListener(){
@Override
public void onCharPrint(char c)
public void onCharPrint(String s)
{
currentLog.append(c);
currentLog.append(s);
}
});
LoggerJava.LoggerOutputStream logErr = new LoggerJava.LoggerOutputStream(System.err, new LoggerJava.OnCharPrintListener(){
@Override
public void onCharPrint(char c)
public void onCharPrint(String s)
{
currentLog.append(c);
currentLog.append(s);
}
});
System.setOut(new PrintStream(logOut));
@@ -480,8 +480,8 @@ public class MCLauncherActivity extends AppCompatActivity
//Downloading libraries
String inputPath = Tools.versnDir + downVName + "_orig.jar";
String multidojClientPath = Tools.versnDir + "/" + p1[0] + "/multidoj";
String patchedFile = multidojClientPath + "/patched" + p1[0] + ".jar";
String unpatchedPath = Tools.versnDir + downVName + "_unpatched.jar";
String patchedFile = Tools.versnDir + downVName + ".jar";
try {
//com.android.dx.mod.Main.debug = true;
@@ -506,7 +506,7 @@ public class MCLauncherActivity extends AppCompatActivity
setMax(libList.length * 2 + 5);
String libPathURL;
File outUndexLib, outDexedLib, outFinishConvert;
File outUndexLib, outDexedLib, outUnpatchedConvert;
for (final DependentLibrary libItem: libList) {
@@ -526,8 +526,7 @@ public class MCLauncherActivity extends AppCompatActivity
outUndexLib.getParentFile().mkdirs();
//if (!oker) throw new RuntimeException(".thehell: " + outUndexLib.getParent());
outDexedLib = new File(Tools.libraries + "/" + Tools.artifactToPath(libInfo[0], libInfo[1], libInfo[2])); // Don't add ".jar"
outFinishConvert = new File(outDexedLib.getParentFile(), "multidoj/finish");
if (!outFinishConvert.exists()) {
if (!outDexedLib.exists()) {
libPathURL = libItem.downloads.artifact.url;
Log.d(Tools.APP_NAME, "Downloading " + libPathURL + " TO FILE " + outUndexLib.getAbsolutePath());
publishProgress("1", getStr(R.string.mcl_launch_download_lib, libItem.name));
@@ -545,7 +544,7 @@ public class MCLauncherActivity extends AppCompatActivity
convertStr = getStr(R.string.mcl_launch_convert_lib, libItem.name);
publishProgress("1", convertStr);
Tools.runDx(MCLauncherActivity.this, outUndexLib.getAbsolutePath(), outDexedLib.getAbsolutePath(), new MultidojManager.Listen(){
Tools.runDx(MCLauncherActivity.this, outUndexLib.getAbsolutePath(), outDexedLib.getAbsolutePath(), new PojavDXManager.Listen(){
@Override
public void onReceived(String step, int maxProg, int currProg)
@@ -562,10 +561,10 @@ public class MCLauncherActivity extends AppCompatActivity
}
*/
if (!outFinishConvert.exists()) {
Error dxError = new Error("DX Error log recorded:\n" + currentLog.toString());
if (!outDexedLib.exists()) {
RuntimeException dxError = new RuntimeException(getResources().getString(R.string.error_convert_lib) + "\n" + currentLog.toString());
dxError.setStackTrace(new StackTraceElement[0]);
throw new RuntimeException(getStr(R.string.error_convert_lib, libItem.name)).initCause(dxError);
}
outUndexLib.delete();
@@ -574,13 +573,12 @@ public class MCLauncherActivity extends AppCompatActivity
}
publishProgress("5", getStr(R.string.mcl_launch_download_client) + p1[0]);
outFinishConvert = new File(multidojClientPath, "finish");
outUnpatchedConvert = new File(unpatchedPath);
if (!new File(patchedFile).exists()) {
// publishProgress("-1", "DEBUG: PatchedFile=" + patchedPath + ";NonExists!");
multidojClientPath = findUnpatch(multidojClientPath);
File outFile = new File(multidojClientPath);
if (!outFile.exists() || !outFinishConvert.exists()) {
// publishProgress("-1", "DEBUG: OutFile=" + outFile + ", OutFinish=" + outFinishConvert + ";NonExists!");
File findUnpatchedConvert = new File(findUnpatch(unpatchedPath));
if (!findUnpatchedConvert.exists()) {
// publishProgress("-1", "DEBUG: OutFile=" + outFile + ", OutFinish=" + outUnpatchedConvert + ";NonExists!");
if (!new File(inputPath).exists()) {
currentLog.setLength(0);
@@ -593,7 +591,7 @@ public class MCLauncherActivity extends AppCompatActivity
convertStr = getStr(R.string.mcl_launch_convert_client, p1[0]);
publishProgress("5", convertStr);
addProgress = 0;
Tools.runDx(MCLauncherActivity.this, inputPath, new File(multidojClientPath).getParent(), new MultidojManager.Listen(){
Tools.runDx(MCLauncherActivity.this, inputPath, outUnpatchedConvert.getAbsolutePath(), new PojavDXManager.Listen(){
@Override
public void onReceived(String step, int maxProg, int currProg)
@@ -603,18 +601,20 @@ public class MCLauncherActivity extends AppCompatActivity
publishProgress("0", convertStr + " (" + currProg + "/" + maxProg + ") " + step, "");
}
});
if (!outFinishConvert.exists()) {
if (!outUnpatchedConvert.exists()) {
Error dxError = new Error("DX Error log recorded:\n" + currentLog.toString());
dxError.setStackTrace(new StackTraceElement[0]);
throw new RuntimeException(getStr(R.string.error_convert_client, p1[0])).initCause(dxError);
}
multidojClientPath = findUnpatch(outFile.getParent());
patchAndCleanJar(p1[0], multidojClientPath, patchedFile);
outUnpatchedConvert = new File(findUnpatch(findUnpatchedConvert.getParent()));
patchAndCleanJar(p1[0], outUnpatchedConvert.getAbsolutePath(), patchedFile);
outUnpatchedConvert.delete();
}
} else {
patchAndCleanJar(p1[0], multidojClientPath, patchedFile);
outUnpatchedConvert = findUnpatchedConvert;
patchAndCleanJar(p1[0], outUnpatchedConvert.getAbsolutePath(), patchedFile);
outUnpatchedConvert.delete();
}
}
} catch (Exception e) {
@@ -624,7 +624,6 @@ public class MCLauncherActivity extends AppCompatActivity
publishProgress("7", getStr(R.string.mcl_launch_cleancache));
new File(inputPath).delete();
new File(multidojClientPath).delete();
File unsignedFile = new File(inputPath);
unsignedFile.delete();

View File

@@ -31,6 +31,7 @@ import org.lwjgl.util.glu.tessellation.*;
import android.graphics.drawable.Drawable;
import android.view.GestureDetector.*;
import java.util.concurrent.locks.*;
import com.kdt.pointer.*;
public class MainActivity extends Activity implements OnTouchListener
{
public static final String initText = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ";
@@ -76,9 +77,12 @@ public class MainActivity extends Activity implements OnTouchListener
private TextView textLog, textLogBehindGL;
private ScrollView contentScroll;
private ToggleButton toggleScrollLog;
private GestureDetector gestureDetector;
private PointerOreoWrapper pointerSurface;
private StringBuilder mQueueText = new StringBuilder();
/*
private LinearLayout contentCanvas;
private AWTSurfaceView contentCanvasView;
@@ -86,6 +90,7 @@ public class MainActivity extends Activity implements OnTouchListener
private boolean lastEnabled = false;
private boolean lastGrab = false;
private boolean isExited = false;
private boolean isLogAllow = false;
private String getStr(int id) {
return getResources().getString(id);
@@ -211,9 +216,10 @@ public class MainActivity extends Activity implements OnTouchListener
this.textLog = (TextView) contentScroll.getChildAt(0);
this.toggleScrollLog = (ToggleButton) findViewById(R.id.content_log_toggle_scrolldown);
this.toggleScrollLog.setChecked(true);
this.textLogBehindGL = findViewById(R.id.main_log_behind_GL);
this.textLogBehindGL = (TextView) findViewById(R.id.main_log_behind_GL);
this.textLogBehindGL.setTypeface(Typeface.MONOSPACE);
/*
this.contentCanvas = (LinearLayout) findViewById(R.id.content_canvas_layout);
this.contentCanvasView = (AWTSurfaceView) findViewById(R.id.content_canvas_view);
@@ -263,11 +269,11 @@ public class MainActivity extends Activity implements OnTouchListener
if (isPointerCaptureSupported()) {
if (!AndroidDisplay.grab && isCapturing) {
glSurfaceView.releasePointerCapture();
pointerSurface.releaseCapture(); // glSurfaceView.releasePointerCapture();
isCapturing = false;
} else if (AndroidDisplay.grab && !isCapturing) {
glSurfaceView.requestFocus();
glSurfaceView.requestPointerCapture();
pointerSurface.requestCapture(); // glSurfaceView.requestPointerCapture();
isCapturing = true;
}
}
@@ -362,6 +368,7 @@ public class MainActivity extends Activity implements OnTouchListener
this.glSurfaceView = (MinecraftGLView) findViewById(R.id.main_game_render_view);
glSurfaceView.setEGLContextClientVersion(2);
final View.OnTouchListener glTouchListener = new OnTouchListener(){
@@ -431,6 +438,19 @@ public class MainActivity extends Activity implements OnTouchListener
// If onClick fail with false, change back to true
}
};
if (isPointerCaptureSupported()) {
this.pointerSurface = new PointerOreoWrapper(glSurfaceView);
this.pointerSurface.setOnCapturedPointerListener(new PointerOreoWrapper.OnCapturedPointerListener(){
@Override
public boolean onCapturedPointer(View view, MotionEvent event)
{
return glTouchListener.onTouch(view, event);
}
});
}
glSurfaceView.setOnHoverListener(new View.OnHoverListener(){
@Override
@@ -496,6 +516,22 @@ public class MainActivity extends Activity implements OnTouchListener
glSurfaceView.setPreserveEGLContextOnPause(true);
glSurfaceView.setRenderMode(MinecraftGLView.RENDERMODE_CONTINUOUSLY);
glSurfaceView.requestRender();
/*
new Thread(new Runnable(){
@Override
public void run()
{
try {
Thread.sleep(5000);
isLogAllow = true;
appendToLog("");
} catch (InterruptedException e) {}
}
}).start();
*/
// Mirror video of OpenGL view.
/*
@@ -656,9 +692,9 @@ public class MainActivity extends Activity implements OnTouchListener
LoggerJava.OnCharPrintListener printLog = new LoggerJava.OnCharPrintListener(){
@Override
public void onCharPrint(char c)
public void onCharPrint(String s)
{
appendToLog(Character.toString(c));
appendToLog(s);
}
};
@@ -669,9 +705,11 @@ public class MainActivity extends Activity implements OnTouchListener
System.setErr(theStreamErr);
String classpath = Tools.generate(mProfile.getVersion());
/*
System.out.println("> Running Minecraft with classpath:");
System.out.println(classpath);
System.out.println();
*/
LaunchClassLoaderAgruments.putAll(classpath, optDir.getAbsolutePath(), getApplicationInfo().nativeLibraryDir);
@@ -736,14 +774,14 @@ public class MainActivity extends Activity implements OnTouchListener
}
private void appendToLog(final String text) {
// test skip
if (true) return;
// mQueueText.append(text);
if (!isLogAllow) {
return;
}
try {
textLog.post(new Runnable(){
private String allText;
@Override
public void run()
{
@@ -761,6 +799,9 @@ public class MainActivity extends Activity implements OnTouchListener
textLogBehindGL.append(text);
}
});
} finally {
mQueueText.setLength(0);
}
}
public void handleMessage(Message msg) {

View File

@@ -7,7 +7,7 @@ import com.kdt.glsupport.*;
public class MinecraftGLView extends GLTextureView
{
private View.OnTouchListener mTouchListener;
// private View.OnTouchListener mTouchListener;
public MinecraftGLView(Context context) {
super(context);
//setPreserveEGLContextOnPause(true);
@@ -17,19 +17,12 @@ public class MinecraftGLView extends GLTextureView
super(context, attributeSet);
//setPreserveEGLContextOnPause(true);
}
/*
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
//super.surfaceDestroyed(surfaceHolder);
System.out.println("Surface destroyed!");
//new Throwable("Surface destroyed!").printStackTrace();
}
*/
@Override
public void setOnTouchListener(View.OnTouchListener l)
{
super.setOnTouchListener(l);
mTouchListener = l;
// mTouchListener = l;
}
@Override
@@ -37,12 +30,5 @@ public class MinecraftGLView extends GLTextureView
{
super.setOnClickListener(l);
}
@Override
public boolean onCapturedPointerEvent(MotionEvent event)
{
mTouchListener.onTouch(this, event);
return super.onCapturedPointerEvent(event);
}
}

View File

@@ -1,18 +0,0 @@
package net.kdt.pojavlaunch;
public class MultidojManager
{
private static Listen li;
public static interface Listen {
public void onReceived(String msg, int max, int current);
}
public static void setListener(Listen l) {
li = l;
}
public static void call(String msg, int max, int current) {
if (li != null) li.onReceived(msg, max, current);
}
}

View File

@@ -0,0 +1,41 @@
package net.kdt.pojavlaunch;
import android.util.*;
public class PojavDXManager
{
private static Listen li;
public static int maxProgress = 0;
public static int currProgress = 0;
public static interface Listen {
public void onReceived(String msg, int max, int current);
}
public static void setListener(Listen l) {
maxProgress = 0;
li = l;
}
public static void call(String msg) {
String[] splitMsg = new String[]{
msg.substring(0, msg.indexOf(" ")),
msg.substring(msg.indexOf(" ") + 1)
};
String firstMsg = splitMsg[0];
if (firstMsg.startsWith("processing")) {
currProgress++;
} else if (firstMsg.startsWith("setmax")) {
maxProgress = Integer.valueOf(splitMsg[1]);
} else if (firstMsg.startsWith("warning")) {
// Nothing
} else if (firstMsg.startsWith("writing")) {
// Nothing
} else {
Log.w("PojavDexer", "Unknown dx operation: " + firstMsg);
}
if (li != null) li.onReceived(msg, maxProgress, currProgress);
}
}

View File

@@ -298,7 +298,7 @@ public class PojavLoginActivity extends MineActivity
Tools.copyAssetOptional(this, "options.txt", Tools.MAIN_PATH + "/gamedir");
//Tools.copyAssetToFolderIfNonExist(this, "dx-f" + (isAndroid7() ? "7" : "4") + ".0.jar", Tools.worksDir, "dx.jar");
Tools.copyAssetOptional(this, "multidoj.dex", Tools.worksDir);
Tools.copyAssetOptional(this, "pojavdx.dex", Tools.worksDir);
// Copy ZIP!!!

View File

@@ -52,52 +52,7 @@ public final class Tools
}
public static String getPatchedFile(String version) {
return versnDir + "/" + version + "/multidoj/patched" + version + ".jar";
}
/*
* Implements to get multidoj dexed folder
*/
//private static boolean isPatched = false;
public static String returnMultidojOrFile(String jarPath, final boolean isClient)
{
//isPatched = false;
if (new File(jarPath).exists()) {
// Check if jar file is exists
return ":" + jarPath;// + ":";
}
StringBuilder sb = new StringBuilder();
File file = new File(jarPath.substring(0, jarPath.lastIndexOf("/")) + "/multidoj");
File[] classes = file.listFiles(new FilenameFilter(){
@Override
public boolean accept(File dir, String name)
{
if (isClient) {
if (name.endsWith(".dex") || name.startsWith("patched")) {
return true;
}
} else {
if (name.endsWith(".dex") || name.endsWith(".jar")) {
return true;
}
}
return false;
}
});
try {
for (File f : classes) {
sb.append(":" + f.getAbsolutePath());// + ":");
}
} catch (Exception e) {
// skip broken library
return "";
}
return ":" + sb.toString();
return versnDir + "/" + version + "/" + version + ".jar";
}
// May useless
@@ -111,10 +66,9 @@ public final class Tools
StringBuilder libStr = new StringBuilder(); //versnDir + "/" + version + "/" + version + ".jar:";
String[] classpath = Tools.generateLibClasspath(Tools.getVersionInfo(version).libraries);
libStr.append(returnMultidojOrFile(versnDir + "/" + version + "/" + version + ".jar", true).substring(1));
//libStr.append(getPatchedFile(version));
for (String perclass : classpath) {
libStr.append(returnMultidojOrFile(perclass, false));
libStr.append(versnDir + "/" + version + "/" + version + ".jar");
for (String perJar : classpath) {
libStr.append(":" + perJar);
}
return libStr.toString();
@@ -275,24 +229,19 @@ public final class Tools
return libDir.toArray(new String[0]);
}
public static void runDx(final Activity ctx, String fileIn, String fileOut, MultidojManager.Listen listener) throws Exception
public static void runDx(final Activity ctx, String fileIn, String fileOut, PojavDXManager.Listen listener) throws Exception
{
MultidojManager.setListener(listener);
PojavDXManager.setListener(listener);
File optDir = ctx.getDir("dalvik-cache", 0);
optDir.mkdirs();
File out = new File(fileOut);
File newFileOut = new File(out.getParent() + File.separator + "multidoj" + File.separator + "resources" + (System.currentTimeMillis()) + ".jar");
newFileOut.getParentFile().mkdirs();
//Class
DexClassLoader mainLoader = new DexClassLoader(Tools.worksDir + "/multidoj.dex", optDir.getAbsolutePath(), ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).applicationInfo.nativeLibraryDir, MainActivity.class.getClassLoader());
DexClassLoader mainLoader = new DexClassLoader(Tools.worksDir + "/pojavdx.dex", optDir.getAbsolutePath(), ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).applicationInfo.nativeLibraryDir, MainActivity.class.getClassLoader());
String receiveMethod = "net.kdt.pojavlaunch.MultidojManager->call(message:String, max:Integer, current:Integer)";
mainLoader.loadClass("com.android.dx.observer.ObserverStatus").getMethod("setReceiver", String.class).invoke(null, receiveMethod);
Class mainClass = mainLoader.loadClass("com.android.dx.command.Main");
Method mainMethod = mainClass.getMethod("main", new String[]{}.getClass());
mainMethod.invoke(null, new Object[]{new String[]{"--dex", "--no-optimize", "--min-sdk-version=" + Build.VERSION.SDK_INT, "--output", newFileOut.getAbsolutePath(), fileIn}});
Method mainMethod = mainClass.getMethod("main", String[].class);
mainMethod.invoke(null, new Object[]{new String[]{"--dex", "--min-sdk-version=" + Build.VERSION.SDK_INT, "--no-optimize", "--output", fileOut, fileIn}});
//com.android.dx.mod.Main.dexTheJar(fileIn, fileOut, ctx.getCacheDir().getAbsolutePath(), listener);