Skip to content

Commit 7aa4443

Browse files
committed
Reapply PR neoforged#1716
1 parent 3704437 commit 7aa4443

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

tests/src/generated/resources/data/data_gen_test/advancement/recipes/building_blocks/conditional.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
}
1212
},
1313
{
14-
"type": "neoforge:item_exists",
15-
"item": "minecraft:dirt"
14+
"type": "neoforge:registered",
15+
"value": "minecraft:dirt"
1616
},
1717
{
18-
"type": "neoforge:false"
18+
"type": "neoforge:never"
1919
}
2020
]
2121
}

tests/src/generated/resources/data/data_gen_test/advancement/recipes/building_blocks/conditional2.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
}
1414
},
1515
{
16-
"type": "neoforge:item_exists",
17-
"item": "minecraft:dirt"
16+
"type": "neoforge:registered",
17+
"value": "minecraft:dirt"
1818
},
1919
{
20-
"type": "neoforge:false"
20+
"type": "neoforge:never"
2121
}
2222
]
2323
}

tests/src/generated/resources/data/data_gen_test/recipe/conditional.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
}
1212
},
1313
{
14-
"type": "neoforge:item_exists",
15-
"item": "minecraft:dirt"
14+
"type": "neoforge:registered",
15+
"value": "minecraft:dirt"
1616
},
1717
{
18-
"type": "neoforge:false"
18+
"type": "neoforge:never"
1919
}
2020
]
2121
}

tests/src/generated/resources/data/data_gen_test/recipe/conditional2.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
}
1414
},
1515
{
16-
"type": "neoforge:item_exists",
17-
"item": "minecraft:dirt"
16+
"type": "neoforge:registered",
17+
"value": "minecraft:dirt"
1818
},
1919
{
20-
"type": "neoforge:false"
20+
"type": "neoforge:never"
2121
}
2222
]
2323
}

tests/src/main/java/net/neoforged/neoforge/oldtest/DataGeneratorTest.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@
8282
import net.neoforged.fml.common.EventBusSubscriber;
8383
import net.neoforged.fml.common.EventBusSubscriber.Bus;
8484
import net.neoforged.fml.common.Mod;
85-
import net.neoforged.neoforge.common.conditions.IConditionBuilder;
86-
import net.neoforged.neoforge.common.conditions.ModLoadedCondition;
85+
import net.neoforged.neoforge.common.conditions.NeoForgeConditions;
8786
import net.neoforged.neoforge.common.conditions.WithConditions;
8887
import net.neoforged.neoforge.common.crafting.CompoundIngredient;
8988
import net.neoforged.neoforge.common.crafting.DifferenceIngredient;
@@ -98,6 +97,7 @@
9897
import net.neoforged.neoforge.common.data.SoundDefinition;
9998
import net.neoforged.neoforge.common.data.SoundDefinitionsProvider;
10099
import net.neoforged.neoforge.data.event.GatherDataEvent;
100+
import net.neoforged.neoforge.internal.versions.neoforge.NeoForgeVersion;
101101
import org.apache.commons.lang3.tuple.Triple;
102102
import org.apache.logging.log4j.LogManager;
103103
import org.apache.logging.log4j.Logger;
@@ -134,8 +134,8 @@ public static void gatherData(GatherDataEvent.Client event) {
134134
new WithConditions<>(new OverlayMetadataSection.OverlayEntry(new InclusiveRange<>(0, Integer.MAX_VALUE), "neoforge_overlays_test")))))
135135
.add(GeneratingOverlayMetadataSection.TYPE, new GeneratingOverlayMetadataSection(List.of(
136136
new WithConditions<>(new OverlayMetadataSection.OverlayEntry(new InclusiveRange<>(0, Integer.MAX_VALUE), "pack_overlays_test")),
137-
new WithConditions<>(new OverlayMetadataSection.OverlayEntry(new InclusiveRange<>(0, Integer.MAX_VALUE), "conditional_overlays_enabled"), new ModLoadedCondition("neoforge")),
138-
new WithConditions<>(new OverlayMetadataSection.OverlayEntry(new InclusiveRange<>(0, Integer.MAX_VALUE), "conditional_overlays_enabled"), new ModLoadedCondition("does_not_exist")))))
137+
new WithConditions<>(new OverlayMetadataSection.OverlayEntry(new InclusiveRange<>(0, Integer.MAX_VALUE), "conditional_overlays_enabled"), NeoForgeConditions.modLoaded(NeoForgeVersion.MOD_ID)),
138+
new WithConditions<>(new OverlayMetadataSection.OverlayEntry(new InclusiveRange<>(0, Integer.MAX_VALUE), "conditional_overlays_enabled"), NeoForgeConditions.modLoaded("does_not_exist")))))
139139
.add(PackMetadataSection.TYPE, new PackMetadataSection(
140140
Component.literal("NeoForge tests resource pack"),
141141
DetectedVersion.BUILT_IN.getPackVersion(PackType.CLIENT_RESOURCES),
@@ -160,7 +160,7 @@ public static void levelStem(BootstrapContext<LevelStem> context) {
160160
context.register(TEST_LEVEL_STEM, levelStem);
161161
}
162162

163-
public static class Recipes extends RecipeProvider implements IConditionBuilder {
163+
public static class Recipes extends RecipeProvider {
164164
public Recipes(HolderLookup.Provider registries, RecipeOutput output) {
165165
super(registries, output);
166166
}
@@ -181,10 +181,10 @@ protected void buildRecipes() {
181181
.unlockedBy("has_dirt", has(Blocks.DIRT))
182182
.save(
183183
output.withConditions(
184-
and(
185-
not(modLoaded("minecraft")),
186-
itemExists("minecraft", "dirt"),
187-
FALSE())),
184+
NeoForgeConditions.and(
185+
NeoForgeConditions.not(NeoForgeConditions.modLoaded("minecraft")),
186+
NeoForgeConditions.itemRegistered("minecraft", "dirt"),
187+
NeoForgeConditions.never())),
188188
recipeKey("conditional"));
189189

190190
this.shaped(RecipeCategory.BUILDING_BLOCKS, Blocks.DIAMOND_BLOCK, 64)
@@ -196,11 +196,11 @@ protected void buildRecipes() {
196196
.unlockedBy("has_dirt", has(Blocks.DIRT))
197197
.save(
198198
output.withConditions(
199-
not(
200-
and(
201-
not(modLoaded("minecraft")),
202-
itemExists("minecraft", "dirt"),
203-
FALSE()))),
199+
NeoForgeConditions.not(
200+
NeoForgeConditions.and(
201+
NeoForgeConditions.not(NeoForgeConditions.modLoaded("minecraft")),
202+
NeoForgeConditions.itemRegistered("minecraft", "dirt"),
203+
NeoForgeConditions.never()))),
204204
recipeKey("conditional2"));
205205

206206
this.shaped(RecipeCategory.BUILDING_BLOCKS, Blocks.NETHERITE_BLOCK, 1)
@@ -211,7 +211,7 @@ protected void buildRecipes() {
211211
.unlockedBy("has_diamond_block", has(Blocks.DIAMOND_BLOCK))
212212
.save(
213213
output.withConditions(
214-
tagEmpty(ItemTags.PLANKS)),
214+
NeoForgeConditions.tagEmpty(ItemTags.PLANKS)),
215215
recipeKey("conditional3"));
216216

217217
this.shaped(RecipeCategory.BUILDING_BLOCKS, Blocks.NETHERITE_BLOCK, 9)
@@ -222,7 +222,7 @@ protected void buildRecipes() {
222222
.unlockedBy("has_diamond_block", has(Blocks.DIAMOND_BLOCK))
223223
.save(
224224
output.withConditions(
225-
not(tagEmpty(ItemTags.PLANKS))),
225+
NeoForgeConditions.not(NeoForgeConditions.tagEmpty(ItemTags.PLANKS))),
226226
recipeKey("conditional4"));
227227

228228
// intersection - should match all non-flammable planks
@@ -486,7 +486,7 @@ protected void addTags(HolderLookup.Provider provider) {
486486
.addTag(BlockTags.STONE_BRICKS)
487487
.addTag(net.neoforged.neoforge.common.Tags.Blocks.COBBLESTONES)
488488
.addOptional(ResourceLocation.fromNamespaceAndPath("chisel", "marble/raw"))
489-
.addOptionalTag(ResourceLocation.fromNamespaceAndPath("neoforge", "storage_blocks/ruby"));
489+
.addOptionalTag(ResourceLocation.fromNamespaceAndPath(NeoForgeVersion.MOD_ID, "storage_blocks/ruby"));
490490

491491
// Hopefully sorting issues
492492
tag(BlockTags.create(ResourceLocation.fromNamespaceAndPath(MODID, "thing/one")))
@@ -581,7 +581,7 @@ public void generate(HolderLookup.Provider registries, Consumer<AdvancementHolde
581581
false,
582582
false)
583583
.addCriterion("get_cobbleStone", InventoryChangeTrigger.TriggerInstance.hasItems(Items.COBBLESTONE))
584-
.parent(ResourceLocation.fromNamespaceAndPath("neoforge", "dummy_parent"))
584+
.parent(ResourceLocation.fromNamespaceAndPath(NeoForgeVersion.MOD_ID, "dummy_parent"))
585585
.save(saver, ResourceLocation.withDefaultNamespace("good_parent"), existingFileHelper);
586586
}
587587
}

0 commit comments

Comments
 (0)