2626
2727import java .io .File ;
2828import java .io .IOException ;
29- import java .io .Reader ;
3029import java .io .UncheckedIOException ;
3130import java .nio .file .Files ;
3231import java .nio .file .Path ;
3332import java .nio .file .StandardCopyOption ;
3433
35- import com .google .gson .Gson ;
36- import com .google .gson .JsonObject ;
37- import com .mojang .serialization .JsonOps ;
38- import dev .architectury .loom .forge .config .InstallProfile ;
3934import org .gradle .api .Project ;
4035import org .jetbrains .annotations .Nullable ;
4136
4237import net .fabricmc .loom .configuration .DependencyInfo ;
4338import net .fabricmc .loom .util .Constants ;
4439import net .fabricmc .loom .util .FileSystemUtil ;
45- import net .fabricmc .loom .util .ZipUtils ;
4640
4741public class PatchProvider extends DependencyProvider {
4842 private final Path projectCacheFolder ;
4943 private File installerJar ;
50- private JsonObject json ;
51- private InstallProfile installProfile ;
5244 private @ Nullable Path clientPatches ;
5345 private @ Nullable Path serverPatches ;
5446
@@ -61,27 +53,13 @@ public PatchProvider(Project project) {
6153 public void provide (DependencyInfo dependency ) throws Exception {
6254 init ();
6355
64- installerJar = new File (getExtension ().getForgeProvider ().getGlobalCache (), "forge-installer.jar" );
65- Path installProfileJson = getExtension ().getForgeProvider ().getGlobalCache ().toPath ().resolve ("forge-installProfile.json" );
66-
67- if (Files .notExists (installProfileJson ) || refreshDeps ()) {
68- File resolved = dependency .resolveFile ().orElseThrow (() -> new RuntimeException ("Could not resolve Forge installer" ));
69- Files .copy (resolved .toPath (), installerJar .toPath (), StandardCopyOption .REPLACE_EXISTING );
70- Files .write (installProfileJson , ZipUtils .unpack (resolved .toPath (), "install_profile.json" ));
71- }
72-
73- try (Reader reader = Files .newBufferedReader (installProfileJson )) {
74- json = new Gson ().fromJson (reader , JsonObject .class );
75- installProfile = InstallProfile .CODEC .parse (JsonOps .INSTANCE , json )
76- .getOrThrow (false , msg -> getProject ().getLogger ().error ("Couldn't read installer install profile, {}" , msg ));
77- }
56+ installerJar = dependency .resolveFile ().orElseThrow (() -> new RuntimeException ("Could not resolve Forge installer" ));
7857 }
7958
8059 public Path extractClientPatches () {
8160 if (clientPatches == null ) {
8261 clientPatches = projectCacheFolder .resolve ("patches-client.lzma" );
83- String binpatchName = installProfile .data ().get ("BINPATCH" ).client ().replaceFirst ("^/data/" , "" );
84- extractPatches (clientPatches , binpatchName );
62+ extractPatches (clientPatches , "client.lzma" );
8563 }
8664
8765 return clientPatches ;
@@ -90,8 +68,7 @@ public Path extractClientPatches() {
9068 public Path extractServerPatches () {
9169 if (serverPatches == null ) {
9270 serverPatches = projectCacheFolder .resolve ("patches-server.lzma" );
93- String binpatchName = installProfile .data ().get ("BINPATCH" ).server ().replaceFirst ("^/data/" , "" );
94- extractPatches (serverPatches , binpatchName );
71+ extractPatches (serverPatches , "server.lzma" );
9572 }
9673
9774 return serverPatches ;
@@ -122,12 +99,4 @@ private void init() {
12299 public String getTargetConfig () {
123100 return Constants .Configurations .FORGE_INSTALLER ;
124101 }
125-
126- public JsonObject getJson () {
127- return json ;
128- }
129-
130- public InstallProfile getInstallProfile () {
131- return installProfile ;
132- }
133102}
0 commit comments