@@ -44,15 +44,18 @@ public final class HypertaleModGatherer {
4444 private final File modSyncBootstrap ;
4545 private final int modHash ;
4646 private final List <ClassPathModCandidate > classPathManifests ;
47+ private final boolean usingMixins ;
4748
4849 private HypertaleModGatherer (List <File > hypertaleMods , List <File > mods , List <File > libraries ,
49- File modSyncBootstrap , int modHash , List <ClassPathModCandidate > classPathManifests ) {
50+ File modSyncBootstrap , int modHash , List <ClassPathModCandidate > classPathManifests ,
51+ boolean usingMixins ) {
5052 this .hypertaleMods = hypertaleMods ;
5153 this .mods = mods ;
5254 this .libraries = libraries ;
5355 this .modSyncBootstrap = modSyncBootstrap ;
5456 this .modHash = modHash ;
5557 this .classPathManifests = classPathManifests ;
58+ this .usingMixins = usingMixins ;
5659 }
5760
5861 public List <File > getHypertaleMods () {
@@ -79,12 +82,17 @@ public List<ClassPathModCandidate> getClassPathManifests() {
7982 return this .classPathManifests ;
8083 }
8184
85+ public boolean isUsingMixins () {
86+ return this .usingMixins ;
87+ }
88+
8289 public static HypertaleModGatherer gatherModsDev () {
8390 return gatherMods (EmptyArrays .EMPTY_STRING_ARRAY );
8491 }
8592
8693 public static HypertaleModGatherer gatherMods (String [] args ) {
8794 // TODO: Process launch arguments
95+ boolean [] useMixins = new boolean []{false };
8896 ArrayList <File > mods = new ArrayList <>();
8997 ArrayList <File > hypertaleMods = new ArrayList <>();
9098 ArrayList <File > libraries = new ArrayList <>();
@@ -93,7 +101,7 @@ public static HypertaleModGatherer gatherMods(String[] args) {
93101 modSyncBootstrap = appendEarlyLoaderMods (mods );
94102 }
95103 if (HypertalePaths .hytaleMods .isDirectory ()) {
96- appendMods (hypertaleMods , mods , libraries );
104+ appendMods (hypertaleMods , mods , libraries , useMixins );
97105 }
98106 long [] fileSizes = new long [mods .size ()];
99107 for (int i = 0 ; i < fileSizes .length ; i ++) {
@@ -103,10 +111,10 @@ public static HypertaleModGatherer gatherMods(String[] args) {
103111 return new HypertaleModGatherer (Collections .unmodifiableList (hypertaleMods ),
104112 Collections .unmodifiableList (mods ), Collections .unmodifiableList (libraries ),
105113 modSyncBootstrap , Arrays .hashCode (fileSizes ),
106- Collections .unmodifiableList (gatherClassPathMods ()) );
114+ Collections .unmodifiableList (gatherClassPathMods (useMixins )), useMixins [ 0 ] );
107115 }
108116
109- private static List <ClassPathModCandidate > gatherClassPathMods () {
117+ private static List <ClassPathModCandidate > gatherClassPathMods (boolean [] useMixins ) {
110118 try {
111119 Enumeration <URL > urlEnumeration = HypertaleModGatherer .class .getClassLoader ().getResources ("manifest.json" );
112120 ArrayList <ClassPathModCandidate > classPathManifests = new ArrayList <>();
@@ -128,6 +136,15 @@ private static List<ClassPathModCandidate> gatherClassPathMods() {
128136 }
129137 }
130138 }
139+ if (!useMixins [0 ]) {
140+ try (InputStream inputStream = url .openStream ()) {
141+ byte [] manifestData = IOUtils .readAllBytes (inputStream );
142+ String modInfo = new String (manifestData , StandardCharsets .UTF_8 );
143+ if (modInfo .contains ("\" HypertaleMixinConfig\" " )) {
144+ useMixins [0 ] = true ;
145+ }
146+ }
147+ }
131148 }
132149 return classPathManifests ;
133150 } catch (Exception e ) {
@@ -151,7 +168,8 @@ private static File appendEarlyLoaderMods(ArrayList<File> mods) {
151168 return modSyncBootstrap ;
152169 }
153170
154- private static void appendMods (ArrayList <File > hypertaleMods , ArrayList <File > mods , ArrayList <File > libraries ) {
171+ private static void appendMods (ArrayList <File > hypertaleMods , ArrayList <File > mods ,
172+ ArrayList <File > libraries , boolean [] useMixins ) {
155173 for (File file : Objects .requireNonNull (HypertalePaths .hytaleMods .listFiles ())) {
156174 if (file .isFile () && file .getName ().endsWith (".jar" ) &&
157175 !file .getName ().equals (HypertalePaths .hypertaleJar .getName ())) {
@@ -168,6 +186,9 @@ private static void appendMods(ArrayList<File> hypertaleMods, ArrayList<File> mo
168186 } catch (RuntimeException _) {
169187 modInfo = "" ;
170188 }
189+ if (modInfo .contains ("\" HypertaleMixinConfig\" " )) {
190+ useMixins [0 ] = true ;
191+ }
171192 if (modInfo .contains ("\" Hypertale" )) {
172193 hypertaleMods .add (file );
173194 mods .add (file );
0 commit comments