Skip to content

Commit 8b04920

Browse files
committed
feat: launcher
1 parent 7218eea commit 8b04920

7 files changed

Lines changed: 188 additions & 99 deletions

File tree

neotenetlauncher/build.gradle

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,15 @@ def buildJarDir = neotenetDir.dir("build/libs")
1818
def neoDevDir = neotenetDir.dir("build/neodev")
1919
def universalJarFile = buildJarDir.file("neotenet-${rootProject.version}-universal.jar")
2020
def installProfile = neoDevDir.file("installer-profile.json")
21-
def serverArgs = neoDevDir.file("unix-server-args.txt")
21+
def unixArgs = neoDevDir.file("unix-server-args.txt")
22+
def winArgs = neoDevDir.file("windows-server-args.txt")
2223
def serverPatch = neoDevDir.file("server-binpatches.lzma")
2324

2425

2526
dependencies {
2627
implementation("com.fasterxml.jackson.core:jackson-databind:2.20.1")
2728

2829
compileOnly "cpw.mods:bootstraplauncher:${project.bootstraplauncher_version}"
29-
compileOnly "net.neoforged.installertools:installertools:2.1.2"
30-
compileOnly "net.neoforged.installertools:jarsplitter:2.1.2"
31-
compileOnly "net.neoforged:AutoRenamingTool:2.0.3"
32-
compileOnly "net.neoforged.installertools:binarypatcher:2.1.2"
3330
}
3431

3532
tasks.register('launcherJar', ShadowJar) {
@@ -51,6 +48,7 @@ tasks.register('launcherJar', ShadowJar) {
5148

5249
from(universalJarFile.asFile) { into('neodev/') }
5350
from(installProfile.asFile) { into('neodev/') }
54-
from(serverArgs.asFile) { into('neodev/') }
51+
from(unixArgs.asFile) { into('neodev/') }
52+
from(winArgs.asFile) { into('neodev/') }
5553
from(serverPatch.asFile) { into('neodev/') }
5654
}

neotenetlauncher/src/main/java/org/teneted/neotenet/launcher/NeoTenetAgent.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public class NeoTenetAgent {
88
public static Instrumentation instrumentation;
99

1010
public static void premain(String args, Instrumentation instrumentation) {
11-
System.out.println("Agent start");
1211
NeoTenetAgent.instrumentation = instrumentation;
1312
}
1413

neotenetlauncher/src/main/java/org/teneted/neotenet/launcher/NeoTenetLauncher.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.teneted.neotenet.launcher;
22

33

4+
import cpw.mods.bootstraplauncher.BootstrapLauncher;
45
import org.teneted.neotenet.launcher.install.Actions;
56

67
public class NeoTenetLauncher {
@@ -13,7 +14,8 @@ public static void main(String[] args) {
1314
System.setProperty("launcher.args", String.join(",", commandLineArgs));
1415

1516
try {
16-
Actions.init(commandLineArgs);
17+
if (!Actions.ready()) Actions.init();
18+
BootstrapLauncher.main(Actions.parseArgs(commandLineArgs));
1719

1820
} catch (Throwable e) {
1921
throw new RuntimeException(e);

neotenetlauncher/src/main/java/org/teneted/neotenet/launcher/install/Actions.java

Lines changed: 154 additions & 90 deletions
Large diffs are not rendered by default.

neotenetlauncher/src/main/java/org/teneted/neotenet/launcher/install/LibrariesAction.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public static void download(List<Library> libraries, File librariesDir) {
3434
System.out.println("Something is wrong...");
3535
}
3636
}
37+
try {
38+
Thread.sleep(5000L);
39+
} catch (InterruptedException e) {
40+
System.out.println("Something is wrong...");
41+
}
3742
}
3843

3944
@Override

neotenetlauncher/src/main/java/org/teneted/neotenet/launcher/utils/FileUtils.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.io.*;
44
import java.net.HttpURLConnection;
55
import java.net.URL;
6+
import java.nio.charset.StandardCharsets;
7+
import java.util.List;
68
import java.util.Random;
79

810
public class FileUtils {
@@ -33,4 +35,23 @@ public static void download(String urlStr, File target) throws IOException {
3335
public static boolean checkFile(File target, String sha1) {
3436
return true;
3537
}
38+
39+
public static void copy(File src, File target) {
40+
try {
41+
if (!target.exists()) target.createNewFile();
42+
FileUtils.copyTo(new FileInputStream(src), new FileOutputStream(target));
43+
} catch (Throwable e) {
44+
throw new RuntimeException(e);
45+
}
46+
}
47+
48+
public static String readText(File argsFile) throws IOException {
49+
ByteArrayOutputStream bos = new ByteArrayOutputStream();
50+
FileUtils.copyTo(new FileInputStream(argsFile), bos);
51+
return bos.toString(StandardCharsets.UTF_8);
52+
}
53+
54+
public static List<String> readTexts(File argsFile) throws IOException {
55+
return List.of(readText(argsFile).split("\n"));
56+
}
3657
}

src/main/java/org/teneted/neotenet/mixin/world/entity/npc/MixinInventoryCarrier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1414

1515
@Mixin(InventoryCarrier.class)
16-
public class MixinInventoryCarrier {
16+
public interface MixinInventoryCarrier {
1717

1818
@Inject(method = "pickUpItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Mob;onItemPickup(Lnet/minecraft/world/entity/item/ItemEntity;)V"), cancellable = true)
1919
private static void neotenet$callEntityPickupItemEvent(Mob p_219612_, InventoryCarrier p_219613_, ItemEntity p_219614_, CallbackInfo ci, @Local SimpleContainer simplecontainer, @Local ItemStack itemstack) {

0 commit comments

Comments
 (0)