feat: properly implement oregen tweaks

This commit is contained in:
Timo Ley 2023-11-29 13:56:47 +01:00
parent 15931cb468
commit 8f843394ac
25 changed files with 61 additions and 35 deletions

View file

@ -0,0 +1,26 @@
package net.anvilcraft.ntx4core;
import java.nio.file.Path;
import net.minecraftforge.forgespi.locating.IModFile;
import net.minecraftforge.resource.PathResourcePack;
public class ModFilePackResources extends PathResourcePack {
protected final IModFile modFile;
protected final String sourcePath;
public ModFilePackResources(String name, IModFile modFile, String sourcePath) {
super(name, modFile.findResource(sourcePath));
this.modFile = modFile;
this.sourcePath = sourcePath;
}
@Override
protected Path resolve(String... paths) {
String[] allPaths = new String[paths.length + 1];
allPaths[0] = sourcePath;
System.arraycopy(paths, 0, allPaths, 1, paths.length);
return modFile.findResource(allPaths);
}
}

View file

@ -12,11 +12,18 @@ import net.anvilcraft.ntx4core.recipes.RecipeReplacements;
import net.anvilcraft.ntx4core.recipes.ShapedRecipes;
import net.anvilcraft.ntx4core.worldgen.Ntx4CoreFeatures;
import net.anvilcraft.ntx4core.worldgen.Ntx4CoreStructures;
import net.minecraft.resource.ResourcePackProfile;
import net.minecraft.resource.ResourcePackSource;
import net.minecraft.resource.ResourceType;
import net.minecraft.util.Identifier;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.AddPackFindersEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.forgespi.language.IModFileInfo;
import net.minecraftforge.forgespi.locating.IModFile;
@Mod("ntx4core")
public class Ntx4Core {
@ -30,6 +37,7 @@ public class Ntx4Core {
Ntx4CoreItems.ITEMS.register(bus);
Ntx4CoreFeatures.STRUCTURE_FEATURES.register(bus);
Ntx4CoreStructures.CONFIGURED_STRUCTURE_FEATURES.register(bus);
bus.addListener(Ntx4Core::addPackFinders);
Bus.MAIN.register(new InputReplacements());
Bus.MAIN.register(new RecipeRemovals());
@ -43,4 +51,25 @@ public class Ntx4Core {
public static Identifier id(String s) {
return new Identifier(MODID, s);
}
public static void addPackFinders(AddPackFindersEvent event) {
if (event.getPackType() == ResourceType.SERVER_DATA) {
IModFileInfo modFileInfo = ModList.get().getModFileById(Ntx4Core.MODID);
if (modFileInfo == null) {
Ntx4Core.LOGGER.error("Could not find Ntx4Core mod file info; built-in resource packs will be missing!");
return;
}
IModFile modFile = modFileInfo.getFile();
event.addRepositorySource(
(consumer, constructor)
-> consumer.accept(ResourcePackProfile.of(
Ntx4Core.id("oregen_tweaks").toString(),
false, () -> new ModFilePackResources("NTX4 Oregen Tweaks", modFile, "datapacks/oregen_tweaks"),
constructor,
ResourcePackProfile.InsertionPosition.TOP,
ResourcePackSource.PACK_SOURCE_NONE
))
);
}
}
}

View file

@ -45,39 +45,4 @@ modId = "anvillib"
mandatory = true
versionRange = "[0.2.0,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.ntx4core]]
modId = "ftbic"
mandatory = false
ordering = "AFTER"
versionRange = "[1802.0.0,)"
side = "BOTH"
[[dependencies.ntx4core]]
modId = "mekanism"
mandatory = false
ordering = "AFTER"
versionRange = "[10.0.0,)"
side = "BOTH"
[[dependencies.ntx4core]]
modId = "crossroads"
mandatory = false
ordering = "AFTER"
versionRange = "[1.18.2,)"
side = "BOTH"
[[dependencies.ntx4core]]
modId = "projectred_exploration"
mandatory = false
ordering = "AFTER"
versionRange = "[4.0.0,)"
side = "BOTH"
[[dependencies.ntx4core]]
modId = "futurepack"
mandatory = false
ordering = "AFTER"
versionRange = "[33.0.0,)"
side = "BOTH"

View file

@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 8,
"description": "NTX4 Oregen Tweaks"
}
}