Skip to content

Commit

Permalink
Remove redundant test
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Nov 27, 2024
1 parent fc5a7a9 commit 58eb1a5
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 80 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.neoforged.neoforge.common.Tags;
import net.neoforged.neoforge.common.conditions.IConditionBuilder;
import net.neoforged.neoforge.event.AddPackFindersEvent;
import net.neoforged.neoforge.event.server.ServerStartedEvent;
Expand Down Expand Up @@ -110,7 +109,6 @@ static void testFlagCondition(DynamicTest test, RegistrationHelper reg) {

var modId = reg.modId();
var enabledRecipeName = ResourceKey.create(Registries.RECIPE, ResourceLocation.fromNamespaceAndPath(modId, "diamonds_from_dirt"));
var disabledRecipeName = ResourceKey.create(Registries.RECIPE, ResourceLocation.fromNamespaceAndPath(modId, "dirt_from_diamonds"));

reg.addProvider(event -> new RecipeProvider.Runner(event.getGenerator().getPackOutput(), event.getLookupProvider()) {
@Override
Expand All @@ -127,12 +125,6 @@ protected void buildRecipes() {
.requires(ItemTags.DIRT)
.unlockedBy("has_dirt", has(ItemTags.DIRT))
.save(output.withConditions(featureFlagsEnabled(flag)), enabledRecipeName);

// recipe available when above flag is disabled
shapeless(RecipeCategory.MISC, Items.DIRT)
.requires(Tags.Items.GEMS_DIAMOND)
.unlockedBy("has_diamond", has(Tags.Items.GEMS_DIAMOND))
.save(output.withConditions(not(featureFlagsEnabled(flag))), disabledRecipeName);
}
}
return new Provider(registries, output);
Expand All @@ -149,22 +141,15 @@ public String getName() {
var isFlagEnabled = server.getWorldData().enabledFeatures().contains(flag);
var recipeMap = server.getRecipeManager().recipeMap();
var hasEnabledRecipe = recipeMap.byKey(enabledRecipeName) != null;
var hasDisabledRecipe = recipeMap.byKey(disabledRecipeName) != null;

if (isFlagEnabled) {
if (!hasEnabledRecipe) {
test.fail("Missing recipe '" + enabledRecipeName.location() + "', This should be enabled due to our flag '" + flagName + "' being enabled");
}
if (hasDisabledRecipe) {
test.fail("Found recipe '" + disabledRecipeName.location() + "', This should be disabled due to our flag '" + flagName + "' being disabled");
}
} else {
if (hasEnabledRecipe) {
test.fail("Found recipe '" + enabledRecipeName.location() + "', This should be disabled due to our flag '" + flagName + "' being enabled");
}
if (!hasDisabledRecipe) {
test.fail("Missing recipe '" + disabledRecipeName.location() + "', This should be enabled due to our flag '" + flagName + "' being disabled");
}
}

test.pass();
Expand Down

0 comments on commit 58eb1a5

Please sign in to comment.