Skip to content

Commit

Permalink
feat(game.enchantment): EnchantmentPredicates
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Oct 9, 2022
1 parent b4e5d65 commit 6bbd6f3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
@@ -0,0 +1,22 @@
package org.auioc.mcmod.arnicalib.game.enchantment;

import java.util.function.Predicate;
import org.auioc.mcmod.arnicalib.game.registry.VanillaPredicates;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.Enchantment.Rarity;

public class EnchantmentPredicates {

public static final Predicate<Enchantment> IS_VANILLA = (e) -> VanillaPredicates.REGISTRY_ENTRY.test(e);

public static final Predicate<Enchantment> IS_TREASURE_ONLY = (e) -> e.isTreasureOnly();
public static final Predicate<Enchantment> IS_CURSE = (e) -> e.isCurse();
public static final Predicate<Enchantment> IS_TRADEABLE = (e) -> e.isTradeable();
public static final Predicate<Enchantment> IS_DISCOVERABLE = (e) -> e.isDiscoverable();

public static final Predicate<Enchantment> IS_COMMON = (e) -> e.getRarity() == Rarity.COMMON;
public static final Predicate<Enchantment> IS_UNCOMMON = (e) -> e.getRarity() == Rarity.UNCOMMON;
public static final Predicate<Enchantment> IS_RARE = (e) -> e.getRarity() == Rarity.RARE;
public static final Predicate<Enchantment> IS_VERY_RARE = (e) -> e.getRarity() == Rarity.VERY_RARE;

}
Expand Up @@ -8,8 +8,11 @@

public class ItemPredicates {

public static final Predicate<ItemStack> IS_VANILLA_ITEM = (itemStack) -> VanillaPredicates.REGISTRY_ENTRY.test(itemStack.getItem());
public static final Predicate<ItemStack> IS_VANILLA = (itemStack) -> VanillaPredicates.REGISTRY_ENTRY.test(itemStack.getItem());
public static final Predicate<Item> IS_AIR = (item) -> item == Items.AIR;
public static final Predicate<Item> IS_CATEGORIZED = (item) -> item.getItemCategory() != null;

@Deprecated(since = "5.6.2", forRemoval = true)
public static final Predicate<ItemStack> IS_VANILLA_ITEM = IS_VANILLA;

}
Expand Up @@ -4,10 +4,10 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistryEntry;

public interface VanillaPredicates {
public class VanillaPredicates {

Predicate<ResourceLocation> ID = (id) -> id.getNamespace().equals("minecraft");
Predicate<String> STRING_ID = (id) -> ID.test(new ResourceLocation(id));
Predicate<ForgeRegistryEntry<?>> REGISTRY_ENTRY = (entry) -> ID.test(entry.getRegistryName());
public static final Predicate<ResourceLocation> ID = (id) -> id.getNamespace().equals("minecraft");
public static final Predicate<String> STRING_ID = (id) -> ID.test(new ResourceLocation(id));
public static final Predicate<ForgeRegistryEntry<?>> REGISTRY_ENTRY = (entry) -> ID.test(entry.getRegistryName());

}

0 comments on commit 6bbd6f3

Please sign in to comment.