From e95053c5ff9085299f3f9e0f3de0a40b0311852c Mon Sep 17 00:00:00 2001 From: 90 Date: Fri, 27 Dec 2024 21:29:44 +0000 Subject: [PATCH 1/2] Do not fail tag datagen when removing IDs not present at runtime (#1798) --- 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..902fb6012ce 100644 --- a/patches/net/minecraft/data/tags/TagsProvider.java.patch +++ b/patches/net/minecraft/data/tags/TagsProvider.java.patch @@ -62,7 +62,7 @@ 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(this::missing) + .toList(); 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 71a734b0ce748f212bd7b5f09da5698d6b9d6e52 Mon Sep 17 00:00:00 2001 From: Matyrobbrt <65940752+Matyrobbrt@users.noreply.github.com> Date: Sat, 28 Dec 2024 16:12:44 +0200 Subject: [PATCH 2/2] Fix index in `ItemHandlerCopySlot#setStackCopy` (#1805) --- .../net/neoforged/neoforge/items/ItemHandlerCopySlot.java | 2 +- .../data_maps/loot_table/effect_grant.json | 4 ---- .../java/net/neoforged/neoforge/debug/data/DataMapTests.java | 4 +++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/neoforged/neoforge/items/ItemHandlerCopySlot.java b/src/main/java/net/neoforged/neoforge/items/ItemHandlerCopySlot.java index 0f7ad24653c..735c036df07 100644 --- a/src/main/java/net/neoforged/neoforge/items/ItemHandlerCopySlot.java +++ b/src/main/java/net/neoforged/neoforge/items/ItemHandlerCopySlot.java @@ -38,7 +38,7 @@ protected ItemStack getStackCopy() { @Override protected void setStackCopy(ItemStack stack) { - ((IItemHandlerModifiable) slotItemHandler.getItemHandler()).setStackInSlot(index, stack); + ((IItemHandlerModifiable) slotItemHandler.getItemHandler()).setStackInSlot(slotItemHandler.index, stack); } @Override diff --git a/tests/src/generated/resources/data/neotests_reloadable_reg_data_maps/data_maps/loot_table/effect_grant.json b/tests/src/generated/resources/data/neotests_reloadable_reg_data_maps/data_maps/loot_table/effect_grant.json index c716281c920..ff7693fcb25 100644 --- a/tests/src/generated/resources/data/neotests_reloadable_reg_data_maps/data_maps/loot_table/effect_grant.json +++ b/tests/src/generated/resources/data/neotests_reloadable_reg_data_maps/data_maps/loot_table/effect_grant.json @@ -3,10 +3,6 @@ "minecraft:blocks/copper_block": { "duration": 100, "id": "minecraft:nausea", - "neoforge:cures": [ - "protected_by_totem", - "milk" - ], "show_icon": true } } diff --git a/tests/src/main/java/net/neoforged/neoforge/debug/data/DataMapTests.java b/tests/src/main/java/net/neoforged/neoforge/debug/data/DataMapTests.java index 8d0f52f2db6..1a6c79b64d4 100644 --- a/tests/src/main/java/net/neoforged/neoforge/debug/data/DataMapTests.java +++ b/tests/src/main/java/net/neoforged/neoforge/debug/data/DataMapTests.java @@ -317,8 +317,10 @@ static void reloadableRegDataMaps(final DynamicTest test, final RegistrationHelp reg.addProvider(event -> new DataMapProvider(event.getGenerator().getPackOutput(), event.getLookupProvider()) { @Override protected void gather() { + var effect = new MobEffectInstance(MobEffects.CONFUSION, 100); + effect.getCures().clear(); // Cures use a hash set (not linked) meaning that their serialization is not deterministic builder(effectGrant) - .add(Blocks.COPPER_BLOCK.getLootTable(), new MobEffectInstance(MobEffects.CONFUSION, 100), false); + .add(Blocks.COPPER_BLOCK.getLootTable(), effect, false); } });