diff --git a/loader/src/main/java/net/neoforged/fml/common/asm/RuntimeDistCleaner.java b/loader/src/main/java/net/neoforged/fml/common/asm/RuntimeDistCleaner.java index 7635eed8e..deea9fe86 100644 --- a/loader/src/main/java/net/neoforged/fml/common/asm/RuntimeDistCleaner.java +++ b/loader/src/main/java/net/neoforged/fml/common/asm/RuntimeDistCleaner.java @@ -7,18 +7,14 @@ import com.google.common.collect.Streams; import com.mojang.logging.LogUtils; -import cpw.mods.jarhandling.SecureJar; import cpw.mods.modlauncher.serviceapi.ILaunchPluginService; import java.util.ArrayList; import java.util.Collections; import java.util.EnumSet; -import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.jar.Attributes; import java.util.stream.Collectors; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; @@ -42,19 +38,10 @@ public class RuntimeDistCleaner implements ILaunchPluginService { private static final Marker DISTXFORM = MarkerFactory.getMarker("DISTXFORM"); private static final String ONLYIN = Type.getDescriptor(OnlyIn.class); private static final String ONLYINS = Type.getDescriptor(OnlyIns.class); - private static final Attributes.Name NAME_DISTS = new Attributes.Name("NeoForm-Minecraft-Dists"); - private static final Attributes.Name NAME_DIST = new Attributes.Name("NeoForm-Minecraft-Dist"); @Nullable private String dist; - /** - * Records which files were masked in a joined distribution because the user requested to run - * in client or server explicitly. The key is the class name while the value is the dist it originally - * comes from. - */ - private final Map maskedClasses = new HashMap<>(); - @Override public String name() { return "runtimedistcleaner"; @@ -67,12 +54,6 @@ public int processClassWithFlags(final Phase phase, final ClassNode classNode, f return ComputeFlags.NO_REWRITE; } - // See if the class we're trying to load was masked - var sourceDist = maskedClasses.get(classNode.name); - if (sourceDist != null && !dist.equals(sourceDist)) { - throw new RuntimeException("Attempted to load class " + classNode.name + " for invalid dist " + dist); - } - AtomicBoolean changes = new AtomicBoolean(); if (remove(classNode.visibleAnnotations, dist)) { LOGGER.error(DISTXFORM, "Attempted to load class {} for invalid dist {}", classNode.name, dist); @@ -163,32 +144,6 @@ private boolean remove(final List anns, final String side) { return unpack(anns).stream().filter(ann -> Objects.equals(ann.desc, ONLYIN)).filter(ann -> !ann.values.contains("_interface")).anyMatch(ann -> !Objects.equals(((String[]) ann.values.get(ann.values.indexOf("value") + 1))[1], side)); } - @Override - public void addResources(List resources) { - for (var resource : resources) { - var manifest = resource.moduleDataProvider().getManifest(); - // Only process manifests of jars that indicate they have multiple source distributions - if (manifest.getMainAttributes().getValue(NAME_DISTS) != null) { - for (var entry : manifest.getEntries().entrySet()) { - String sourceDist = switch (entry.getValue().getValue(NAME_DIST)) { - case "client" -> Dist.CLIENT.name(); - case "server" -> Dist.DEDICATED_SERVER.name(); - case null, default -> null; - }; - if (sourceDist == null) { - continue; - } - - var path = entry.getKey(); - if (path.endsWith(".class")) { - var key = path.substring(0, path.length() - ".class".length()); - maskedClasses.put(key, sourceDist); - } - } - } - } - } - public void setDistribution(@Nullable Dist dist) { if (dist != null) { this.dist = dist.name(); diff --git a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/locators/NeoForgeDevProvider.java b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/locators/NeoForgeDevProvider.java index c13e08e27..1a568d292 100644 --- a/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/locators/NeoForgeDevProvider.java +++ b/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/locators/NeoForgeDevProvider.java @@ -34,8 +34,8 @@ */ public class NeoForgeDevProvider implements IModFileCandidateLocator { private static final Logger LOG = LoggerFactory.getLogger(NeoForgeDevProvider.class); - private static final Attributes.Name NAME_DISTS = new Attributes.Name("NeoForm-Minecraft-Dists"); - private static final Attributes.Name NAME_DIST = new Attributes.Name("NeoForm-Minecraft-Dist"); + private static final Attributes.Name NAME_DISTS = new Attributes.Name("Minecraft-Dists"); + private static final Attributes.Name NAME_DIST = new Attributes.Name("Minecraft-Dist"); private final List paths;