Skip to content

Commit

Permalink
Doing some hacky stuff to improve core mod support. Removing debug st…
Browse files Browse the repository at this point in the history
…uff from System.out. Some minimal branding.
  • Loading branch information
Arminias committed Apr 24, 2022
1 parent af3f998 commit b280cbd
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ task wrapper(type: Wrapper) {
sourceCompatibility = 1.8
targetCompatibility = 1.8

archivesBaseName = "cursed-fabric-loader"
archivesBaseName = "cursed-fabric-loader-btw"

// Fetch build number from Jenkins
def ENV = System.getenv()
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
org.gradle.jvmargs=-Xmx1536M

# Basic stuff
modid = cursed-fabric-loader
modid = cursed-fabric-loader-btw
group = io.github.minecraft-cursed-legacy
description = The mod loading component of Fabric
url = https://github.com/minecraft-cursed-legacy/cursed-fabric-loader
url = https://github.com/BTW-Community/cursed-fabric-loader

version = 1.0.0
version = 1.1.0
asm_version = 9.1

maven_url=gcs://devan-maven
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected void compute() {
// Optional (custom values)
Map<String, CustomValue> customValues = new HashMap<>();
info = new LoaderModMetadata[]{
new V1ModMetadata(path.getFileName().toString().replace(".", ""),
new V1ModMetadata("coremod" + path.getFileName().toString().replace(".jar", "").toLowerCase().replaceAll("[^a-z]", ""),
new StringVersion("1.0.0"), provides, environment, entrypoints, jars, mixins, accessWidener, depends, recommends, suggests, conflicts, breaks, requires, name, description, authors, contributors, contact, license, icon, languageAdapters, customValues)
};
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public TinyRemapperWithOverwrites(TinyRemapper t) {
TinyRemapper.class.getDeclaredField("dirty"),
TinyRemapper.class.getDeclaredField("readClasses"),
TinyRemapper.class.getDeclaredField("classesToMakePublic"),
TinyRemapper.class.getDeclaredField("membersToMakePublic"),
ClassInstance.class.getDeclaredField("isInput"),
ClassInstance.class.getDeclaredField("srcPath"),
ClassInstance.class.getDeclaredField("name"),
Expand Down Expand Up @@ -125,6 +126,17 @@ public void readInputs(InputTag tag, Path... inputs) {
read(inputs, true, tag);
}

private static void makeMembersPublic(ClassInstance cls) {
try {
Set<MemberInstance> membersToMakePublic = (Set<MemberInstance>) ((Field) accessMap.get("field_membersToMakePublic")).get(INSTANCE);
for (MemberInstance member : cls.getMembers()) {
membersToMakePublic.add(member);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}

public List<ClassInstance> read(Path[] inputs, boolean isInput, InputTag tag) {
InputTag[] tags = new InputTag[0];
try {
Expand Down Expand Up @@ -207,19 +219,29 @@ private static void addClass(ClassInstance cls, Map<String, ClassInstance> out,
for (;;) {
ClassInstance prev = out.putIfAbsent(name, cls);
ClassInstance prev_mapped = out.putIfAbsent(mapped_name, cls);
if (prev == null && prev_mapped == null) return;
if (prev == null && prev_mapped == null) {
((Set<ClassInstance>)classesToMakePublic.get(INSTANCE)).add(cls);
makeMembersPublic(cls);
return;
}
if (prev != null) {
if ((boolean) isInput.get(cls)) {
if ((boolean) isInput.get(prev)) {
System.out.printf("duplicate input class %s, from %s and %s%n", name, srcPath.get(prev), srcPath.get(cls));
//LOGGER.debug("duplicate input class %s, from %s and %s", name, srcPath.get(prev), srcPath.get(cls));
addInputTags.invoke(prev, getInputTags.invoke(cls));
((Set<ClassInstance>)classesToMakePublic.get(INSTANCE)).add(prev);
makeMembersPublic(prev);
return;
} else if (out.replace(name, prev, cls)) { // cas with retry-loop on failure
addInputTags.invoke(cls, getInputTags.invoke(prev));
((Set<ClassInstance>)classesToMakePublic.get(INSTANCE)).add(cls);
makeMembersPublic(cls);
return;
}
} else {
addInputTags.invoke(prev, getInputTags.invoke(cls));
((Set<ClassInstance>)classesToMakePublic.get(INSTANCE)).add(prev);
makeMembersPublic(prev);
return;
}
}
Expand All @@ -228,13 +250,18 @@ private static void addClass(ClassInstance cls, Map<String, ClassInstance> out,
if ((boolean) isInput.get(prev_mapped)) {
addInputTags.invoke(prev_mapped, getInputTags.invoke(cls));
((Set<ClassInstance>)classesToMakePublic.get(INSTANCE)).add(prev_mapped);
makeMembersPublic(prev_mapped);
return;
} else if (out.replace(name, prev_mapped, cls)) { // cas with retry-loop on failure
addInputTags.invoke(cls, getInputTags.invoke(prev_mapped));
((Set<ClassInstance>)classesToMakePublic.get(INSTANCE)).add(cls);
makeMembersPublic(cls);
return;
}
} else {
addInputTags.invoke(prev_mapped, getInputTags.invoke(cls));
((Set<ClassInstance>)classesToMakePublic.get(INSTANCE)).add(prev_mapped);
makeMembersPublic(prev_mapped);
return;
}
}
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/net/fabricmc/loader/launch/knot/Knot.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
import org.objectweb.asm.commons.Remapper;
import org.spongepowered.asm.launch.MixinBootstrap;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.net.URL;
import java.nio.file.Path;
import java.util.*;
Expand Down Expand Up @@ -112,12 +110,23 @@ protected ClassLoader init(String[] args) {

if (provider.isObfuscated()) {
for (Path path : provider.getGameContextJars()) {
PrintStream out = System.out;
// The Remapper lib partly uses System.out for debugging
if (!LOGGER.isDebugEnabled()) {
System.setOut(new PrintStream(new OutputStream() {
public void write(int b) {}
}));
}
FabricLauncherBase.deobfuscate(
provider.getGameId(), provider.getNormalizedGameVersion(),
provider.getLaunchDirectory(),
path,
this
);
// And lets restore it again
if (!LOGGER.isDebugEnabled()) {
System.setOut(out);
}
}
}

Expand Down

0 comments on commit b280cbd

Please sign in to comment.