[1.19.3] Add ability to datagen forge specific values in pack.mcmeta (#9221)

Co-authored-by: sciwhiz12 <sciwhiz12@gmail.com>
This commit is contained in:
Minecraftschurliandsciwhiz12 authored and GitHub committed 2022-12-16 16:52:54 +00:00
1 parent 9c66928854
commit 84d7a0facb
2 files changed
+28 -1

No files matched your search

@@ -55,6 +55,7 @@ import net.minecraft.network.chat.TextColor;
import net.minecraft.network.chat.contents.LiteralContents;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.metadata.pack.PackMetadataSection;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagEntry;
import net.minecraft.tags.TagKey;
@@ -1520,7 +1521,7 @@ public class ForgeHooks
for (PackType packType : PackType.values())
{
String key = "forge:" + packType.bridgeType.name().toLowerCase(Locale.ROOT) + "_pack_format";
String key = makePackFormatKey(packType);
if (json.has(key))
{
map.put(packType, GsonHelper.getAsInt(json, key));
@@ -1530,6 +1531,24 @@ public class ForgeHooks
return map.buildOrThrow();
}
public static void writeTypedPackFormats(JsonObject json, PackMetadataSection section)
{
int packFormat = section.getPackFormat();
for (PackType packType : PackType.values())
{
int format = section.getPackFormat(packType);
if (format != packFormat)
{
json.addProperty(makePackFormatKey(packType), format);
}
}
}
private static String makePackFormatKey(PackType packType)
{
return "forge:" + packType.bridgeType.name().toLowerCase(Locale.ROOT) + "_pack_format";
}
/**
* <p>
* This method is used to prefix the path, where elements of the associated registry are stored, with their namespace, if it is not minecraft