From 0a981729802f7746c8fe1349fac8b21f075f1d37 Mon Sep 17 00:00:00 2001
From: Anselm Brehme
Date: Thu, 30 May 2024 18:25:55 +0200
Subject: [PATCH] enchantment tags
---
.../api/item/enchantment/Enchantment.java | 9 --
.../api/item/enchantment/EnchantmentType.java | 12 ++-
.../api/tag/EnchantmenTypeTags.java | 90 +++++++++++++++++++
3 files changed, 99 insertions(+), 12 deletions(-)
create mode 100644 src/main/java/org/spongepowered/api/tag/EnchantmenTypeTags.java
diff --git a/src/main/java/org/spongepowered/api/item/enchantment/Enchantment.java b/src/main/java/org/spongepowered/api/item/enchantment/Enchantment.java
index 11fa050be7f..c4fffd8f620 100644
--- a/src/main/java/org/spongepowered/api/item/enchantment/Enchantment.java
+++ b/src/main/java/org/spongepowered/api/item/enchantment/Enchantment.java
@@ -194,15 +194,6 @@ interface RandomListBuilder extends org.spongepowered.api.util.BuilderIf empty a pool will be calculated based on the other values instead.
diff --git a/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentType.java b/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentType.java
index 35997c8fb1f..b3dececc7a9 100644
--- a/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentType.java
+++ b/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentType.java
@@ -28,13 +28,15 @@
import org.spongepowered.api.block.entity.EnchantmentTable;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.registry.DefaultedRegistryValue;
+import org.spongepowered.api.tag.EnchantmenTypeTags;
+import org.spongepowered.api.tag.Taggable;
import org.spongepowered.api.util.annotation.CatalogedBy;
/**
* Represents a modifier on an item that has various effects.
*/
@CatalogedBy(EnchantmentTypes.class)
-public interface EnchantmentType extends DefaultedRegistryValue, ComponentLike {
+public interface EnchantmentType extends DefaultedRegistryValue, ComponentLike, Taggable {
/**
* Gets the weight of this enchantment type.
@@ -114,7 +116,9 @@ public interface EnchantmentType extends DefaultedRegistryValue, ComponentLike {
*
* @return Whether this enchantment type is a treasure enchantment type
*/
- boolean isTreasure();
+ default boolean isTreasure() {
+ return this.is(EnchantmenTypeTags.TREASURE);
+ }
/**
* Gets whether or not this enchantment type is considered a "curse"
@@ -122,6 +126,8 @@ public interface EnchantmentType extends DefaultedRegistryValue, ComponentLike {
*
* @return Whether this enchantment type is a curse enchantment type
*/
- boolean isCurse();
+ default boolean isCurse() {
+ return this.is(EnchantmenTypeTags.CURSE);
+ }
}
diff --git a/src/main/java/org/spongepowered/api/tag/EnchantmenTypeTags.java b/src/main/java/org/spongepowered/api/tag/EnchantmenTypeTags.java
new file mode 100644
index 00000000000..8aa8690bbf8
--- /dev/null
+++ b/src/main/java/org/spongepowered/api/tag/EnchantmenTypeTags.java
@@ -0,0 +1,90 @@
+/*
+ * This file is part of SpongeAPI, licensed under the MIT License (MIT).
+ *
+ * Copyright (c) SpongePowered
+ * Copyright (c) contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package org.spongepowered.api.tag;
+
+import org.spongepowered.api.ResourceKey;
+import org.spongepowered.api.item.enchantment.EnchantmentType;
+import org.spongepowered.api.registry.RegistryScope;
+import org.spongepowered.api.registry.RegistryScopes;
+import org.spongepowered.api.registry.RegistryTypes;
+
+/**
+ *
+ */
+@SuppressWarnings("unused")
+@RegistryScopes(scopes = RegistryScope.GAME)
+public final class EnchantmenTypeTags {
+
+ public static final Tag CURSE = EnchantmenTypeTags.key(ResourceKey.minecraft("curse"));
+
+ public static final Tag DOUBLE_TRADE_PRICE = EnchantmenTypeTags.key(ResourceKey.minecraft("double_trade_price"));
+
+ public static final Tag EXCLUSIVE_SET_ARMOR = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/armor"));
+
+ public static final Tag EXCLUSIVE_SET_BOOTS = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/boots"));
+
+ public static final Tag EXCLUSIVE_SET_BOW = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/bow"));
+
+ public static final Tag EXCLUSIVE_SET_CROSSBOW = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/crossbow"));
+
+ public static final Tag EXCLUSIVE_SET_DAMAGE = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/damage"));
+
+ public static final Tag EXCLUSIVE_SET_MINING = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/mining"));
+
+ public static final Tag EXCLUSIVE_SET_RIPTIDE = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/riptide"));
+
+ public static final Tag IN_ENCHANTING_TABLE = EnchantmenTypeTags.key(ResourceKey.minecraft("in_enchanting_table"));
+
+ public static final Tag NON_TREASURE = EnchantmenTypeTags.key(ResourceKey.minecraft("non_treasure"));
+
+ public static final Tag ON_MOB_SPAWN_EQUIPMENT = EnchantmenTypeTags.key(ResourceKey.minecraft("on_mob_spawn_equipment"));
+
+ public static final Tag ON_RANDOM_LOOT = EnchantmenTypeTags.key(ResourceKey.minecraft("on_random_loot"));
+
+ public static final Tag ON_TRADED_EQUIPMENT = EnchantmenTypeTags.key(ResourceKey.minecraft("on_traded_equipment"));
+
+ public static final Tag PREVENTS_BEE_SPAWNS_WHEN_MINING = EnchantmenTypeTags.key(ResourceKey.minecraft("prevents_bee_spawns_when_mining"));
+
+ public static final Tag PREVENTS_DECORATED_POT_SHATTERING = EnchantmenTypeTags.key(ResourceKey.minecraft("prevents_decorated_pot_shattering"));
+
+ public static final Tag PREVENTS_ICE_MELTING = EnchantmenTypeTags.key(ResourceKey.minecraft("prevents_ice_melting"));
+
+ public static final Tag PREVENTS_INFESTED_SPAWNS = EnchantmenTypeTags.key(ResourceKey.minecraft("prevents_infested_spawns"));
+
+ public static final Tag SMELTS_LOOT = EnchantmenTypeTags.key(ResourceKey.minecraft("smelts_loot"));
+
+ public static final Tag TOOLTIP_ORDER = EnchantmenTypeTags.key(ResourceKey.minecraft("tooltip_order"));
+
+ public static final Tag TRADEABLE = EnchantmenTypeTags.key(ResourceKey.minecraft("tradeable"));
+
+ public static final Tag TREASURE = EnchantmenTypeTags.key(ResourceKey.minecraft("treasure"));
+
+ private EnchantmenTypeTags() {
+ }
+
+ private static Tag key(final ResourceKey key) {
+ return Tag.of(RegistryTypes.ENCHANTMENT_TYPE, key);
+ }
+}