-
-
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.
- Loading branch information
1 parent
c0dbe21
commit 7730007
Showing
9 changed files
with
63 additions
and
176 deletions.
There are no files selected for viewing
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
38 changes: 38 additions & 0 deletions
38
src/main/java/net/neoforged/neoforge/common/conditions/FeatureFlagsEnabledCondition.java
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.common.conditions; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.world.flag.FeatureFlag; | ||
import net.minecraft.world.flag.FeatureFlagSet; | ||
import net.minecraft.world.flag.FeatureFlags; | ||
|
||
/** | ||
* Condition checking that a set of {@link FeatureFlag feature flags} are enabled. | ||
* | ||
* @apiNote Mainly to be used when flagged content is not contained within the same feature pack which also enables said {@link FeatureFlag feature flags}. | ||
*/ | ||
public record FeatureFlagsEnabledCondition(FeatureFlagSet flags) implements ICondition { | ||
public static final MapCodec<FeatureFlagsEnabledCondition> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( | ||
FeatureFlags.CODEC.fieldOf("flags").forGetter(condition -> condition.flags)).apply(instance, FeatureFlagsEnabledCondition::new)); | ||
|
||
public FeatureFlagsEnabledCondition { | ||
if (flags.isEmpty()) { | ||
throw new IllegalArgumentException("FeatureFlagsEnabledCondition requires a non-empty feature flag set"); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean test(IContext context) { | ||
return flags.isSubsetOf(context.enabledFeatures()); | ||
} | ||
|
||
@Override | ||
public MapCodec<? extends ICondition> codec() { | ||
return CODEC; | ||
} | ||
} |
72 changes: 0 additions & 72 deletions
72
src/main/java/net/neoforged/neoforge/common/conditions/FlagCondition.java
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...ources/data/neotests_test_flag_condition/advancement/recipes/misc/diamonds_from_dirt.json
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
41 changes: 0 additions & 41 deletions
41
...ources/data/neotests_test_flag_condition/advancement/recipes/misc/dirt_from_diamonds.json
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
.../src/generated/resources/data/neotests_test_flag_condition/recipe/diamonds_from_dirt.json
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
20 changes: 0 additions & 20 deletions
20
.../src/generated/resources/data/neotests_test_flag_condition/recipe/dirt_from_diamonds.json
This file was deleted.
Oops, something went wrong.
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