-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.20.4] Fixed NeoForge pack version and description (Attempt 2) (#365)
This is a **breaking change** because we are removing the obsolete server/resource pack numbers because vanilla allows us to specify version ranges. Mods can just say they can run on all versions and avoid the red highlighting in pack screens entirely.
- Loading branch information
1 parent
84d25b7
commit f7049ed
Showing
6 changed files
with
20 additions
and
76 deletions.
There are no files selected for viewing
57 changes: 2 additions & 55 deletions
57
patches/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,11 @@ | ||
--- a/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java | ||
+++ b/net/minecraft/server/packs/metadata/pack/PackMetadataSection.java | ||
@@ -9,14 +_,59 @@ | ||
import net.minecraft.server.packs.metadata.MetadataSectionType; | ||
import net.minecraft.util.InclusiveRange; | ||
|
||
-public record PackMetadataSection(Component description, int packFormat, Optional<InclusiveRange<Integer>> supportedFormats) { | ||
+public record PackMetadataSection(Component description, @Deprecated int packFormat, Optional<InclusiveRange<Integer>> supportedFormats, Optional<NeoForgeData> neoForgeData) { | ||
public static final Codec<PackMetadataSection> CODEC = RecordCodecBuilder.create( | ||
p_304321_ -> p_304321_.group( | ||
ComponentSerialization.CODEC.fieldOf("description").forGetter(PackMetadataSection::description), | ||
Codec.INT.fieldOf("pack_format").forGetter(PackMetadataSection::packFormat), | ||
- InclusiveRange.codec(Codec.INT).optionalFieldOf("supported_formats").forGetter(PackMetadataSection::supportedFormats) | ||
+ InclusiveRange.codec(Codec.INT).optionalFieldOf("supported_formats").forGetter(PackMetadataSection::supportedFormats), | ||
+ NeoForgeData.CODEC.optionalFieldOf("neoforge").forGetter(PackMetadataSection::neoForgeData) | ||
) | ||
@@ -19,4 +_,8 @@ | ||
.apply(p_304321_, PackMetadataSection::new) | ||
); | ||
public static final MetadataSectionType<PackMetadataSection> TYPE = MetadataSectionType.fromCodec("pack", CODEC); | ||
+ | ||
+ @Deprecated | ||
+ public PackMetadataSection(Component description, int packFormat, Optional<InclusiveRange<Integer>> supportedFormats) { | ||
+ this(description, packFormat, supportedFormats, Optional.empty()); | ||
+ } | ||
+ | ||
+ public PackMetadataSection(Component description, int packFormat, InclusiveRange<Integer> supportedFormats) { | ||
+ this(description, packFormat, Optional.of(supportedFormats), Optional.empty()); | ||
+ } | ||
+ | ||
+ public PackMetadataSection(Component description, int packFormat, NeoForgeData neoForgeData) { | ||
+ this(description, packFormat, Optional.empty(), Optional.of(neoForgeData)); | ||
+ } | ||
+ | ||
+ public <R> PackMetadataSection(Component p_10371_, int p_10372_, java.util.Map<net.minecraft.server.packs.PackType, Integer> packTypeVersions) { | ||
+ this(p_10371_, p_10372_, new NeoForgeData(packTypeVersions)); | ||
+ } | ||
+ | ||
+ public PackMetadataSection(Component description, int packVersion) { | ||
+ this(description, packVersion, Optional.empty(), Optional.empty()); | ||
+ } | ||
+ | ||
+ public int packFormat(net.minecraft.server.packs.PackType packType) { | ||
+ return neoForgeData().flatMap(d -> d.packFormat(packType)).orElse(packFormat()); | ||
+ } | ||
+ | ||
+ public record NeoForgeData(Optional<java.util.Map<net.minecraft.server.packs.PackType, Integer>> formatPerPackType) { | ||
+ | ||
+ private static final Codec<NeoForgeData> CODEC = RecordCodecBuilder.create(builder -> builder.group( | ||
+ Codec.simpleMap( | ||
+ net.minecraft.util.StringRepresentable.fromEnum(net.minecraft.server.packs.PackType::values), | ||
+ Codec.INT, | ||
+ com.mojang.serialization.Keyable.forStrings(() -> java.util.Arrays.stream(net.minecraft.server.packs.PackType.values()).map(net.minecraft.util.StringRepresentable::getSerializedName)) | ||
+ ).codec().optionalFieldOf("versions").forGetter(NeoForgeData::formatPerPackType) | ||
+ ).apply(builder, NeoForgeData::new)); | ||
+ | ||
+ public NeoForgeData(java.util.Map<net.minecraft.server.packs.PackType, Integer> supportedFormats) { | ||
+ this(Optional.of(supportedFormats)); | ||
+ } | ||
+ | ||
+ public Optional<Integer> packFormat(net.minecraft.server.packs.PackType packType) { | ||
+ return formatPerPackType.map(p -> p.get(packType)); | ||
+ } | ||
+ this(description, packVersion, Optional.empty()); | ||
+ } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters