From f56c15ef91aec14a50c827ceafe27105ea973f59 Mon Sep 17 00:00:00 2001 From: 90 Date: Tue, 24 Dec 2024 13:39:42 +0000 Subject: [PATCH 1/2] [1.21.1] Do not fail tag datagen when removing IDs not present at runtime --- patches/net/minecraft/data/tags/TagsProvider.java.patch | 2 +- .../resources/data/minecraft/tags/block/test_tag.json | 3 ++- .../net/neoforged/neoforge/oldtest/RemoveTagDatagenTest.java | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/patches/net/minecraft/data/tags/TagsProvider.java.patch b/patches/net/minecraft/data/tags/TagsProvider.java.patch index 7cf15ff1f62..714f2f5829b 100644 --- a/patches/net/minecraft/data/tags/TagsProvider.java.patch +++ b/patches/net/minecraft/data/tags/TagsProvider.java.patch @@ -64,7 +64,7 @@ - List list1 = list.stream().filter(p_274771_ -> !p_274771_.verifyIfPresent(predicate, predicate1)).toList(); + List list1 = java.util.stream.Stream.concat(list.stream(), tagbuilder.getRemoveEntries()) + .filter((p_274771_) -> !p_274771_.verifyIfPresent(predicate, predicate1)) -+ .filter(this::missing) ++ .filter(entry -> tagbuilder.getRemoveEntries().noneMatch(entry::equals) && this.missing(entry)) + .toList(); if (!list1.isEmpty()) { throw new IllegalArgumentException( diff --git a/tests/src/generated/resources/data/minecraft/tags/block/test_tag.json b/tests/src/generated/resources/data/minecraft/tags/block/test_tag.json index cfe909e22ba..ebd314ac3ec 100644 --- a/tests/src/generated/resources/data/minecraft/tags/block/test_tag.json +++ b/tests/src/generated/resources/data/minecraft/tags/block/test_tag.json @@ -8,7 +8,8 @@ "minecraft:polished_andesite", "#minecraft:beehives", "#minecraft:banners", - "#minecraft:beds" + "#minecraft:beds", + "minecraft:dacite" ], "values": [] } \ No newline at end of file diff --git a/tests/src/main/java/net/neoforged/neoforge/oldtest/RemoveTagDatagenTest.java b/tests/src/main/java/net/neoforged/neoforge/oldtest/RemoveTagDatagenTest.java index 7ac89d1be14..7ab7609506f 100644 --- a/tests/src/main/java/net/neoforged/neoforge/oldtest/RemoveTagDatagenTest.java +++ b/tests/src/main/java/net/neoforged/neoforge/oldtest/RemoveTagDatagenTest.java @@ -46,7 +46,9 @@ protected void addTags(HolderLookup.Provider provider) { .remove(key(Blocks.ANVIL)) .remove(key(Blocks.BASALT), key(Blocks.POLISHED_ANDESITE)) .remove(BlockTags.BEEHIVES) - .remove(BlockTags.BANNERS, BlockTags.BEDS); + .remove(BlockTags.BANNERS, BlockTags.BEDS) + // test removing optional IDs not present at run-time + .remove(ResourceLocation.withDefaultNamespace("dacite")); } }; From b89b10fed676ce5f507a761c43c86ab3b5f6c0f7 Mon Sep 17 00:00:00 2001 From: 90 Date: Fri, 27 Dec 2024 12:34:56 +0000 Subject: [PATCH 2/2] Remove redundant stream concatenation and later check --- patches/net/minecraft/data/tags/TagsProvider.java.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/net/minecraft/data/tags/TagsProvider.java.patch b/patches/net/minecraft/data/tags/TagsProvider.java.patch index 714f2f5829b..902fb6012ce 100644 --- a/patches/net/minecraft/data/tags/TagsProvider.java.patch +++ b/patches/net/minecraft/data/tags/TagsProvider.java.patch @@ -62,9 +62,9 @@ TagBuilder tagbuilder = p_323138_.getValue(); List list = tagbuilder.build(); - List list1 = list.stream().filter(p_274771_ -> !p_274771_.verifyIfPresent(predicate, predicate1)).toList(); -+ List list1 = java.util.stream.Stream.concat(list.stream(), tagbuilder.getRemoveEntries()) ++ List list1 = list.stream() + .filter((p_274771_) -> !p_274771_.verifyIfPresent(predicate, predicate1)) -+ .filter(entry -> tagbuilder.getRemoveEntries().noneMatch(entry::equals) && this.missing(entry)) ++ .filter(this::missing) + .toList(); if (!list1.isEmpty()) { throw new IllegalArgumentException(