Skip to content

Commit

Permalink
Fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Apr 4, 2024
1 parent 479331d commit 2838faf
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 408 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ private synchronized void setupMinecraft(ConfigContext configContext) throws Exc
namedMinecraftProvider.provide(provideContext);

if (extension.isForge()) {
final SrgMinecraftProvider<?> srgMinecraftProvider = jarConfiguration.getSrgMinecraftProviderBiFunction().apply(project, minecraftProvider);
final SrgMinecraftProvider<?> srgMinecraftProvider = jarConfiguration.createSrgMinecraftProvider(project);
extension.setSrgMinecraftProvider(srgMinecraftProvider);
srgMinecraftProvider.provide(provideContext);
} else if (extension.isNeoForge()) {
final MojangMappedMinecraftProvider<?> mojangMappedMinecraftProvider = jarConfiguration.getMojangMappedMinecraftProviderBiFunction().apply(project, minecraftProvider);
final MojangMappedMinecraftProvider<?> mojangMappedMinecraftProvider = jarConfiguration.createMojangMappedMinecraftProvider(project);
extension.setMojangMappedMinecraftProvider(mojangMappedMinecraftProvider);
mojangMappedMinecraftProvider.provide(provideContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.fabricmc.loom.configuration.ConfigContext;
import net.fabricmc.loom.configuration.providers.forge.MinecraftPatchedProvider;
import net.fabricmc.loom.configuration.providers.minecraft.MergedMinecraftProvider;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMetadataProvider;
import net.fabricmc.loom.configuration.providers.minecraft.SingleJarMinecraftProvider;

/**
Expand All @@ -37,15 +38,15 @@
public interface ForgeMinecraftProvider {
MinecraftPatchedProvider getPatchedProvider();

static MergedMinecraftProvider createMerged(ConfigContext context) {
return LoomGradleExtension.get(context.project()).isForgeLike() ? new MergedForgeMinecraftProvider(context) : new MergedMinecraftProvider(context);
static MergedMinecraftProvider createMerged(MinecraftMetadataProvider metadataProvider, ConfigContext context) {
return LoomGradleExtension.get(context.project()).isForgeLike() ? new MergedForgeMinecraftProvider(metadataProvider, context) : new MergedMinecraftProvider(metadataProvider, context);
}

static SingleJarMinecraftProvider createServerOnly(ConfigContext context) {
return LoomGradleExtension.get(context.project()).isForgeLike() ? SingleJarForgeMinecraftProvider.server(context) : SingleJarMinecraftProvider.server(context);
static SingleJarMinecraftProvider createServerOnly(MinecraftMetadataProvider metadataProvider, ConfigContext context) {
return LoomGradleExtension.get(context.project()).isForgeLike() ? SingleJarForgeMinecraftProvider.forgeServer(metadataProvider, context) : SingleJarMinecraftProvider.server(metadataProvider, context);
}

static SingleJarMinecraftProvider createClientOnly(ConfigContext context) {
return LoomGradleExtension.get(context.project()).isForgeLike() ? SingleJarForgeMinecraftProvider.client(context) : SingleJarMinecraftProvider.client(context);
static SingleJarMinecraftProvider createClientOnly(MinecraftMetadataProvider metadataProvider, ConfigContext context) {
return LoomGradleExtension.get(context.project()).isForgeLike() ? SingleJarForgeMinecraftProvider.forgeClient(metadataProvider, context) : SingleJarMinecraftProvider.client(metadataProvider, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
import net.fabricmc.loom.configuration.ConfigContext;
import net.fabricmc.loom.configuration.providers.forge.MinecraftPatchedProvider;
import net.fabricmc.loom.configuration.providers.minecraft.MergedMinecraftProvider;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMetadataProvider;

public final class MergedForgeMinecraftProvider extends MergedMinecraftProvider implements ForgeMinecraftProvider {
private final MinecraftPatchedProvider patchedProvider;

public MergedForgeMinecraftProvider(ConfigContext configContext) {
super(configContext);
public MergedForgeMinecraftProvider(MinecraftMetadataProvider metadataProvider, ConfigContext configContext) {
super(metadataProvider, configContext);
this.patchedProvider = new MinecraftPatchedProvider(configContext.project(), this, MinecraftPatchedProvider.Type.MERGED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,112 @@
import java.nio.file.Path;
import java.util.List;

import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
import net.fabricmc.loom.configuration.ConfigContext;
import net.fabricmc.loom.configuration.providers.BundleMetadata;
import net.fabricmc.loom.configuration.providers.forge.MinecraftPatchedProvider;
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftMetadataProvider;
import net.fabricmc.loom.configuration.providers.minecraft.SingleJarEnvType;
import net.fabricmc.loom.configuration.providers.minecraft.SingleJarMinecraftProvider;

public final class SingleJarForgeMinecraftProvider extends SingleJarMinecraftProvider implements ForgeMinecraftProvider {
public abstract class SingleJarForgeMinecraftProvider extends SingleJarMinecraftProvider implements ForgeMinecraftProvider {
private final MinecraftPatchedProvider patchedProvider;

private SingleJarForgeMinecraftProvider(ConfigContext configContext, SingleJarMinecraftProvider.Environment environment) {
super(configContext, environment);

Check failure on line 40 in src/main/java/net/fabricmc/loom/configuration/providers/forge/minecraft/SingleJarForgeMinecraftProvider.java

View workflow job for this annotation

GitHub Actions / build (8.6.0-jdk17)

trailing whitespace
private SingleJarForgeMinecraftProvider(MinecraftMetadataProvider metadataProvider, ConfigContext configContext) {
super(metadataProvider, configContext, MappingsNamespace.OFFICIAL);
this.patchedProvider = new MinecraftPatchedProvider(configContext.project(), this, provideServer() ? MinecraftPatchedProvider.Type.SERVER_ONLY : MinecraftPatchedProvider.Type.CLIENT_ONLY);
}

public static SingleJarForgeMinecraftProvider server(ConfigContext configContext) {
return new SingleJarForgeMinecraftProvider(configContext, new Server());

Check failure on line 45 in src/main/java/net/fabricmc/loom/configuration/providers/forge/minecraft/SingleJarForgeMinecraftProvider.java

View workflow job for this annotation

GitHub Actions / build (8.6.0-jdk17)

trailing whitespace
public static SingleJarForgeMinecraftProvider.Server forgeServer(MinecraftMetadataProvider metadataProvider, ConfigContext configContext) {
return new SingleJarForgeMinecraftProvider.Server(metadataProvider, configContext);
}

public static SingleJarForgeMinecraftProvider client(ConfigContext configContext) {
return new SingleJarForgeMinecraftProvider(configContext, new Client());
public static SingleJarForgeMinecraftProvider.Client forgeClient(MinecraftMetadataProvider metadataProvider, ConfigContext configContext) {
return new SingleJarForgeMinecraftProvider.Client(metadataProvider, configContext);
}

@Override
protected boolean provideClient() {
// the client jar is needed for client-extra which the Forge userdev launch thing always checks for
return true;
}

@Override
protected void processJar() throws Exception {
// don't process the jar, it's created by the patched provider
}

@Override
public MinecraftPatchedProvider getPatchedProvider() {
return patchedProvider;
}

@Override
public Path getMinecraftEnvOnlyJar() {
return patchedProvider.getMinecraftPatchedJar();
}

@Override
public List<Path> getMinecraftJars() {
return List.of(patchedProvider.getMinecraftPatchedJar());
}

public static final class Server extends SingleJarForgeMinecraftProvider {
private Server(MinecraftMetadataProvider metadataProvider, ConfigContext configContext) {
super(metadataProvider, configContext);
}

@Override
public SingleJarEnvType type() {
return SingleJarEnvType.SERVER;
}

@Override
public Path getInputJar(SingleJarMinecraftProvider provider) throws Exception {
BundleMetadata serverBundleMetadata = provider.getServerBundleMetadata();

if (serverBundleMetadata == null) {
return provider.getMinecraftServerJar().toPath();
}

provider.extractBundledServerJar();
return provider.getMinecraftExtractedServerJar().toPath();
}

@Override
protected boolean provideServer() {
return true;
}

@Override
protected boolean provideClient() {
return false;
}
}

public static final class Client extends SingleJarForgeMinecraftProvider {
private Client(MinecraftMetadataProvider metadataProvider, ConfigContext configContext) {
super(metadataProvider, configContext);
}

@Override
public SingleJarEnvType type() {
return SingleJarEnvType.CLIENT;
}

@Override
public Path getInputJar(SingleJarMinecraftProvider provider) throws Exception {
return provider.getMinecraftClientJar().toPath();
}

@Override
protected boolean provideServer() {
return false;
}

@Override
protected boolean provideClient() {
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public record MinecraftJarConfiguration<
MinecraftProviderFactory<M> minecraftProviderFactory,
IntermediaryMinecraftProviderFactory<M> intermediaryMinecraftProviderFactory,
NamedMinecraftProviderFactory<M> namedMinecraftProviderFactory,
SrgMinecraftProviderFactory<M> srgMinecraftProviderFactory,
MojangMappedMinecraftProviderFactory<M> mojangMappedMinecraftProviderFactory,
ProcessedNamedMinecraftProviderFactory<M, N> processedNamedMinecraftProviderFactory,
DecompileConfigurationFactory<Q> decompileConfigurationFactory,
List<String> supportedEnvironments) {
Expand All @@ -72,6 +74,8 @@ public record MinecraftJarConfiguration<
LegacyMergedMinecraftProvider::new,
IntermediaryMinecraftProvider.LegacyMergedImpl::new,
NamedMinecraftProvider.LegacyMergedImpl::new,
SrgMinecraftProvider.LegacyMergedImpl::new,
MojangMappedMinecraftProvider.LegacyMergedImpl::new,
ProcessedNamedMinecraftProvider.LegacyMergedImpl::new,
SingleJarDecompileConfiguration::new,
List.of("client", "server")
Expand Down Expand Up @@ -128,6 +132,14 @@ public NamedMinecraftProvider<M> createNamedMinecraftProvider(Project project) {
return namedMinecraftProviderFactory.create(project, getMinecraftProvider(project));
}

public SrgMinecraftProvider<M> createSrgMinecraftProvider(Project project) {
return srgMinecraftProviderFactory.create(project, getMinecraftProvider(project));
}

public MojangMappedMinecraftProvider<M> createMojangMappedMinecraftProvider(Project project) {
return mojangMappedMinecraftProviderFactory.create(project, getMinecraftProvider(project));
}

public ProcessedNamedMinecraftProvider<M, N> createProcessedNamedMinecraftProvider(NamedMinecraftProvider<?> namedMinecraftProvider, MinecraftJarProcessorManager jarProcessorManager) {
return processedNamedMinecraftProviderFactory.create((N) namedMinecraftProvider, jarProcessorManager);
}
Expand All @@ -148,14 +160,6 @@ private Q getMappedMinecraftProvider(Project project) {
return (Q) extension.getNamedMinecraftProvider();
}

public BiFunction<Project, MinecraftProvider, SrgMinecraftProvider<?>> getSrgMinecraftProviderBiFunction() {
return srgMinecraftProviderBiFunction;
}

public BiFunction<Project, MinecraftProvider, MojangMappedMinecraftProvider<?>> getMojangMappedMinecraftProviderBiFunction() {
return mojangMappedMinecraftProviderBiFunction;
}

public List<String> getSupportedEnvironments() {
return supportedEnvironments;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected boolean provideServer() {

public void provide() throws Exception {
if (getExtension().shouldGenerateSrgTiny() && !getExtension().isForgeLike()) {
getProject().getDependencies().add(Constants.Configurations.SRG, "de.oceanlabs.mcp:mcp_config:" + minecraftVersion);
getProject().getDependencies().add(Constants.Configurations.SRG, "de.oceanlabs.mcp:mcp_config:" + minecraftVersion());
}

initFiles();
Expand Down Expand Up @@ -134,8 +134,8 @@ private void downloadJars() throws IOException {
}
}
}

protected final void extractBundledServerJar() throws IOException {

Check failure on line 137 in src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftProvider.java

View workflow job for this annotation

GitHub Actions / build (8.6.0-jdk17)

trailing whitespace
public final void extractBundledServerJar() throws IOException {
Preconditions.checkArgument(provideServer(), "Not configured to provide server jar");
Objects.requireNonNull(getServerBundleMetadata(), "Cannot bundled mc jar from none bundled server jar");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import net.fabricmc.tinyremapper.OutputConsumerPath;
import net.fabricmc.tinyremapper.TinyRemapper;

public abstract sealed class SingleJarMinecraftProvider extends MinecraftProvider permits SingleJarMinecraftProvider.Server, SingleJarMinecraftProvider.Client {
public abstract class SingleJarMinecraftProvider extends MinecraftProvider {
private final MappingsNamespace officialNamespace;
private Path minecraftEnvOnlyJar;

Expand Down Expand Up @@ -127,9 +127,9 @@ public MappingsNamespace getOfficialNamespace() {
return officialNamespace;
}

abstract SingleJarEnvType type();

abstract Path getInputJar(SingleJarMinecraftProvider provider) throws Exception;
protected abstract SingleJarEnvType type();

Check failure on line 131 in src/main/java/net/fabricmc/loom/configuration/providers/minecraft/SingleJarMinecraftProvider.java

View workflow job for this annotation

GitHub Actions / build (8.6.0-jdk17)

trailing whitespace
protected abstract Path getInputJar(SingleJarMinecraftProvider provider) throws Exception;

public static final class Server extends SingleJarMinecraftProvider {
private Server(MinecraftMetadataProvider metadataProvider, ConfigContext configContext, MappingsNamespace officialNamespace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import java.util.List;

import net.fabricmc.loom.configuration.providers.minecraft.LegacyMergedMinecraftProvider;

import org.gradle.api.Project;

Check failure on line 31 in src/main/java/net/fabricmc/loom/configuration/providers/minecraft/mapped/MojangMappedMinecraftProvider.java

View workflow job for this annotation

GitHub Actions / build (8.6.0-jdk17)

Wrong order for 'org.gradle.api.Project' import.

import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
Expand All @@ -37,7 +39,7 @@
import net.fabricmc.loom.util.SidedClassVisitor;
import net.fabricmc.tinyremapper.TinyRemapper;

public abstract sealed class MojangMappedMinecraftProvider<M extends MinecraftProvider> extends AbstractMappedMinecraftProvider<M> permits MojangMappedMinecraftProvider.MergedImpl, MojangMappedMinecraftProvider.SingleJarImpl, MojangMappedMinecraftProvider.SplitImpl {
public abstract sealed class MojangMappedMinecraftProvider<M extends MinecraftProvider> extends AbstractMappedMinecraftProvider<M> permits MojangMappedMinecraftProvider.MergedImpl, MojangMappedMinecraftProvider.LegacyMergedImpl, MojangMappedMinecraftProvider.SingleJarImpl, MojangMappedMinecraftProvider.SplitImpl {
public MojangMappedMinecraftProvider(Project project, M minecraftProvider) {
super(project, minecraftProvider);
}
Expand Down Expand Up @@ -65,6 +67,18 @@ public List<RemappedJars> getRemappedJars() {
}
}

public static final class LegacyMergedImpl extends MojangMappedMinecraftProvider<LegacyMergedMinecraftProvider> implements Merged {
public LegacyMergedImpl(Project project, LegacyMergedMinecraftProvider minecraftProvider) {
super(project, minecraftProvider);
}

@Override
public List<RemappedJars> getRemappedJars() {
// The delegate providers will handle the remapping
throw new UnsupportedOperationException("LegacyMergedImpl does not support getRemappedJars");
}
}

public static final class SplitImpl extends MojangMappedMinecraftProvider<SplitMinecraftProvider> implements Split {
public SplitImpl(Project project, SplitMinecraftProvider minecraftProvider) {
super(project, minecraftProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import java.util.List;

import net.fabricmc.loom.configuration.providers.minecraft.LegacyMergedMinecraftProvider;

import org.gradle.api.Project;

Check failure on line 31 in src/main/java/net/fabricmc/loom/configuration/providers/minecraft/mapped/SrgMinecraftProvider.java

View workflow job for this annotation

GitHub Actions / build (8.6.0-jdk17)

Wrong order for 'org.gradle.api.Project' import.

import net.fabricmc.loom.api.mappings.layered.MappingsNamespace;
Expand All @@ -37,7 +39,7 @@
import net.fabricmc.loom.util.SidedClassVisitor;
import net.fabricmc.tinyremapper.TinyRemapper;

public abstract sealed class SrgMinecraftProvider<M extends MinecraftProvider> extends AbstractMappedMinecraftProvider<M> permits SrgMinecraftProvider.MergedImpl, SrgMinecraftProvider.SingleJarImpl, SrgMinecraftProvider.SplitImpl {
public abstract sealed class SrgMinecraftProvider<M extends MinecraftProvider> extends AbstractMappedMinecraftProvider<M> permits SrgMinecraftProvider.MergedImpl, SrgMinecraftProvider.LegacyMergedImpl, SrgMinecraftProvider.SingleJarImpl, SrgMinecraftProvider.SplitImpl {
public SrgMinecraftProvider(Project project, M minecraftProvider) {
super(project, minecraftProvider);
}
Expand Down Expand Up @@ -65,6 +67,18 @@ public List<RemappedJars> getRemappedJars() {
}
}

public static final class LegacyMergedImpl extends SrgMinecraftProvider<LegacyMergedMinecraftProvider> implements Merged {
public LegacyMergedImpl(Project project, LegacyMergedMinecraftProvider minecraftProvider) {
super(project, minecraftProvider);
}

@Override
public List<RemappedJars> getRemappedJars() {
// The delegate providers will handle the remapping
throw new UnsupportedOperationException("LegacyMergedImpl does not support getRemappedJars");
}
}

public static final class SplitImpl extends SrgMinecraftProvider<SplitMinecraftProvider> implements Split {
public SplitImpl(Project project, SplitMinecraftProvider minecraftProvider) {
super(project, minecraftProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void addBaseForgeSources(Project project) throws IOException {
minecraftJar = minecraftJars.get(0);
}

Path sourcesJar = GenerateSourcesTask.getMappedJarFileWithSuffix("-sources.jar", minecraftJar).toPath();
Path sourcesJar = GenerateSourcesTask.getJarFileWithSuffix("-sources.jar", minecraftJar).toPath();

if (!Files.exists(sourcesJar)) {
try (var serviceManager = new ScopedSharedServiceManager()) {
Expand Down
Loading

0 comments on commit 2838faf

Please sign in to comment.