Skip to content

Commit

Permalink
add downloadMojangMappings task
Browse files Browse the repository at this point in the history
  • Loading branch information
supersaiyansubtlety committed Nov 27, 2024
1 parent d5b8b3e commit c38bfc4
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ public interface Extensions {
String UNPICK = Constants.UNPICK_NAME;
String GZ = "gz";
String JSON = "json";
String TXT = "txt";
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import quilt.internal.task.VersionParserConsumingTask;
import quilt.internal.task.setup.DownloadMinecraftJarsTask;
import quilt.internal.task.setup.DownloadMinecraftLibrariesTask;
import quilt.internal.task.setup.DownloadMojangMappingsTask;
import quilt.internal.task.setup.DownloadWantedVersionManifestTask;
import quilt.internal.task.setup.ExtractServerJarTask;
import quilt.internal.task.setup.MergeJarsTask;
Expand Down Expand Up @@ -98,9 +99,9 @@ protected MinecraftJarsExtension applyImpl(@NotNull Project project) {
downloadMinecraftJars.flatMap(DownloadMinecraftJarsTask::getServerBootstrapJar)
);

task.getExtractionDest().convention(
this.provideMinecraftBuildFile(quiltExt.provideSuffixedMinecraftVersion("-server." + Extensions.JAR))
);
task.getExtractionDest().convention(this.provideMinecraftBuildFile(
quiltExt.provideSuffixedMinecraftVersion("-server." + Extensions.JAR)
));
}
);

Expand All @@ -112,9 +113,9 @@ protected MinecraftJarsExtension applyImpl(@NotNull Project project) {

task.getServerJar().convention(extractServerJar.flatMap(ExtractServerJarTask::getExtractionDest));

task.getMergedFile().convention(
this.provideMinecraftBuildFile(quiltExt.provideSuffixedMinecraftVersion("-merged." + Extensions.JAR))
);
task.getMergedFile().convention(this.provideMinecraftBuildFile(
quiltExt.provideSuffixedMinecraftVersion("-merged." + Extensions.JAR)
));
}
);

Expand All @@ -126,6 +127,20 @@ protected MinecraftJarsExtension applyImpl(@NotNull Project project) {
}
);

tasks.register(
DownloadMojangMappingsTask.DOWNLOAD_MOJANG_MAPPINGS_TASK_NAME,
DownloadMojangMappingsTask.class,
task -> {
task.getClientMappings().convention(
this.getMinecraftBuildDir().map(dir -> dir.file("client." + Extensions.TXT))
);

task.getServerMappings().convention(
this.getMinecraftBuildDir().map(dir -> dir.file("server." + Extensions.TXT))
);
}
);

return project.getExtensions().create(
MinecraftJarsExtension.NAME, MinecraftJarsExtension.class,
new Tasks(mergeJars, downloadMinecraftLibraries)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package quilt.internal.task.setup;

import org.gradle.api.DefaultTask;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
import org.quiltmc.launchermeta.version.v1.Downloads;
import quilt.internal.constants.Groups;
import quilt.internal.plugin.MinecraftJarsPlugin;
import quilt.internal.task.VersionParserConsumingTask;
import quilt.internal.util.DownloadUtil;

/**
* Downloads Mojang's client and server mappings for the passed {@linkplain #getVersionParser version}.
*
* @see <a href=https://minecraft.wiki/w/Obfuscation_map>Obfuscation map</a>
* @see MinecraftJarsPlugin MinecraftJarsPlugin's configureEach
*/
public abstract class DownloadMojangMappingsTask extends DefaultTask implements VersionParserConsumingTask {
/**
* {@linkplain org.gradle.api.tasks.TaskContainer#register Registered} by
* {@link MinecraftJarsPlugin MinecraftJarsPlugin}.
*/
public static final String DOWNLOAD_MOJANG_MAPPINGS_TASK_NAME = "downloadMojangMappings";

@OutputFile
public abstract RegularFileProperty getClientMappings();

@OutputFile
public abstract RegularFileProperty getServerMappings();

public DownloadMojangMappingsTask() {
this.setGroup(Groups.SETUP);
}

@TaskAction
public void download() {
final Downloads downloads = this.getVersionParser().get().get().getDownloads();

downloads.getClientMappings().ifPresentOrElse(
clientMappings -> DownloadUtil.download(
clientMappings.getUrl(),
this.getClientMappings().get().getAsFile(),
false, this.getLogger()
),
() -> this.getLogger().warn("No client mappings available")
);

downloads.getServerMappings().ifPresentOrElse(
serverMappings -> DownloadUtil.download(
serverMappings.getUrl(),
this.getServerMappings().get().getAsFile(),
false, this.getLogger()
),
() -> this.getLogger().warn("No server mappings available")
);
}
}

1 comment on commit c38bfc4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With commit c38bfc4, 4 file(s) were updated with 7 line(s) added and 7 removed compared to the latest Quilt Mappings version.

View the diff here:
diff -bur namedTargetSrc/net/minecraft/world/chunk/ChunkCache.java namedSrc/net/minecraft/world/chunk/ChunkCache.java
--- namedTargetSrc/net/minecraft/world/chunk/ChunkCache.java	2024-11-27 02:54:14.341763283 +0000
+++ namedSrc/net/minecraft/world/chunk/ChunkCache.java	2024-11-27 02:53:07.421890721 +0000
@@ -135,7 +135,7 @@
     * Mapping not found
     */
    @Override
-   public List<VoxelShape> getEntityCollisions(@Nullable Entity entity, Box box) {
+   public List<VoxelShape> getEntityCollisions(@Nullable Entity entity, Box arg2) {
       return List.of();
    }
 
diff -bur namedTargetSrc/net/minecraft/world/CollisionView.java namedSrc/net/minecraft/world/CollisionView.java
--- namedTargetSrc/net/minecraft/world/CollisionView.java	2024-11-27 02:54:14.285763379 +0000
+++ namedSrc/net/minecraft/world/CollisionView.java	2024-11-27 02:53:07.337890902 +0000
@@ -124,7 +124,7 @@
     * @mapping {@literal hashed m_lrisnbsp Lnet/minecraft/unmapped/C_vxzrjtdu;m_lrisnbsp(Lnet/minecraft/unmapped/C_astfners;Lnet/minecraft/unmapped/C_hbcjzgoe;)Ljava/util/List;}
     * @mapping {@literal named getEntityCollisions Lnet/minecraft/world/CollisionView;getEntityCollisions(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/Box;)Ljava/util/List;}
     */
-   List<VoxelShape> getEntityCollisions(@Nullable Entity entity, Box box);
+   List<VoxelShape> getEntityCollisions(@Nullable Entity entity, Box arg2);
 
    /**
     * @mapping {@literal hashed m_ypwqnrxo Lnet/minecraft/unmapped/C_vxzrjtdu;m_ypwqnrxo(Lnet/minecraft/unmapped/C_astfners;Lnet/minecraft/unmapped/C_hbcjzgoe;)Ljava/lang/Iterable;}
diff -bur namedTargetSrc/net/minecraft/world/RegistryWorldView.java namedSrc/net/minecraft/world/RegistryWorldView.java
--- namedTargetSrc/net/minecraft/world/RegistryWorldView.java	2024-11-27 02:54:14.421763147 +0000
+++ namedSrc/net/minecraft/world/RegistryWorldView.java	2024-11-27 02:53:07.517890515 +0000
@@ -20,16 +20,16 @@
     * Mapping not found
     */
    @Override
-   default <T extends BlockEntity> Optional<T> getBlockEntity(BlockPos pos, BlockEntityType<T> arg2) {
-      return WorldView.super.getBlockEntity(pos, arg2);
+   default <T extends BlockEntity> Optional<T> getBlockEntity(BlockPos pos, BlockEntityType<T> type) {
+      return WorldView.super.getBlockEntity(pos, type);
    }
 
    /**
     * Mapping not found
     */
    @Override
-   default List<VoxelShape> getEntityCollisions(@Nullable Entity entity, Box box) {
-      return EntityView.super.getEntityCollisions(entity, box);
+   default List<VoxelShape> getEntityCollisions(@Nullable Entity entity, Box arg2) {
+      return EntityView.super.getEntityCollisions(entity, arg2);
    }
 
    /**
diff -bur namedTargetSrc/net/minecraft/world/TestableWorld.java namedSrc/net/minecraft/world/TestableWorld.java
--- namedTargetSrc/net/minecraft/world/TestableWorld.java	2024-11-27 02:54:14.285763379 +0000
+++ namedSrc/net/minecraft/world/TestableWorld.java	2024-11-27 02:53:07.341890894 +0000
@@ -29,7 +29,7 @@
     * @mapping {@literal hashed m_mfgvkamg Lnet/minecraft/unmapped/C_agsukcmb;m_mfgvkamg(Lnet/minecraft/unmapped/C_hynzadkk;Lnet/minecraft/unmapped/C_wgqvodus;)Ljava/util/Optional;}
     * @mapping {@literal named getBlockEntity Lnet/minecraft/world/TestableWorld;getBlockEntity(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/entity/BlockEntityType;)Ljava/util/Optional;}
     */
-   <T extends BlockEntity> Optional<T> getBlockEntity(BlockPos pos, BlockEntityType<T> arg2);
+   <T extends BlockEntity> Optional<T> getBlockEntity(BlockPos pos, BlockEntityType<T> type);
 
    /**
     * @mapping {@literal hashed m_yirkkvqk Lnet/minecraft/unmapped/C_agsukcmb;m_yirkkvqk(Lnet/minecraft/unmapped/C_ybztoekc$C_wkdeqzbn;Lnet/minecraft/unmapped/C_hynzadkk;)Lnet/minecraft/unmapped/C_hynzadkk;}

Please sign in to comment.