Skip to content

Commit

Permalink
Provide a dummy RP for mods that base their own pack's ordering off it
Browse files Browse the repository at this point in the history
See: ARRP
  • Loading branch information
Matyrobbrt committed Jan 20, 2024
1 parent f687ac9 commit acbce72
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ fabric-client-tags-api-v1-version=1.1.1
loom.platform=forge
forge_version=1.20.1-47.2.6
pack_format=15
forgified_version=1.10.7
forgified_version=1.10.8
forge_fabric_loader_version=2.6.0+0.15.0+1.20.1
7 changes: 6 additions & 1 deletion gradle/ffapi-setup.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import java.nio.file.StandardCopyOption

allprojects {
if (name == 'deprecated') return
final selfProject = it

sourceSets.configureEach { sourceSet ->
// We have to capture the source set name for the lazy string literals,
Expand All @@ -53,6 +54,7 @@ allprojects {
packFormat = rootProject.pack_format.toInteger()
addMixinConfigs = sourceSet.name.startsWith("test")
accessWidener = loom.accessWidenerPath
containsCode = selfProject === rootProject
}
sourceSet.resources.srcDir task

Expand Down Expand Up @@ -336,6 +338,9 @@ abstract class GenerateForgeModMetadata extends DefaultTask {
@Input
final Property<String> forgeVersionString = project.objects.property(String)

@Input
final Property<Boolean> containsCode = project.objects.property(Boolean)

@Input
final Property<String> minecraftVersionString = project.objects.property(String)

Expand Down Expand Up @@ -387,7 +392,7 @@ abstract class GenerateForgeModMetadata extends DefaultTask {
def run() {
def output = outputDir.get().asFile.toPath()
output.deleteDir()
def containsCode = sourceRoots.any { new File(it.parentFile, "java").exists() }
def containsCode = sourceRoots.any { new File(it.parentFile, "java").exists() } || this.containsCode.get()
for (def sourceRoot in sourceRoots) {
if (!sourceRoot.isDirectory()) {
continue
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/net/fabricmc/fabric/impl/sinytra/SinytraFabric.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package net.fabricmc.fabric.impl.sinytra;

import net.minecraft.resource.DirectoryResourcePack;
import net.minecraft.resource.ResourcePackProfile;

import net.minecraft.resource.ResourcePackSource;
import net.minecraft.text.Text;

import net.minecraftforge.event.AddPackFindersEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

@Mod("fabric_api")
public class SinytraFabric {
public SinytraFabric() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(EventPriority.NORMAL, false, AddPackFindersEvent.class, this::addPackFinder);
}

/**
* Some mods (ARRP) may use a resource pack named {@code fabric} to sort their own packs around. So just provide it.
*/
private void addPackFinder(AddPackFindersEvent event) {
event.addRepositorySource(profileAdder -> profileAdder.accept(
ResourcePackProfile.create(
"fabric",
Text.of("fabric"),
true,
name -> new DirectoryResourcePack(name, ModList.get().getModContainerById("fabric_api").get().getModInfo().getOwningFile()
.getFile().findResource("dummyrp"), true),
event.getPackType(),
ResourcePackProfile.InsertionPosition.TOP,
ResourcePackSource.BUILTIN
)
));
}
}
8 changes: 8 additions & 0 deletions src/main/resources/dummyrp/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"pack": {
"description": {
"text": "fabric_api dummy resources"
},
"pack_format": 15
}
}

0 comments on commit acbce72

Please sign in to comment.