Skip to content

Commit

Permalink
enchantment tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Faithcaio committed May 30, 2024
1 parent 1f58dc5 commit 0a98172
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,6 @@ interface RandomListBuilder extends org.spongepowered.api.util.Builder<List<Ench
*/
RandomListBuilder level(int level);

/**
* Sets whether to include treasure enchantments or not
*
* @param treasure whether to include treasure enchantments or not
*
* @return The modified builder, for chaining
*/
RandomListBuilder treasure(boolean treasure);

/**
* Sets a fixed pool for the random enchantments to pick from.
* <p>If empty a pool will be calculated based on the other values instead.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EnchantmentType> {

/**
* Gets the weight of this enchantment type.
Expand Down Expand Up @@ -114,14 +116,18 @@ 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"
* enchantment.
*
* @return Whether this enchantment type is a curse enchantment type
*/
boolean isCurse();
default boolean isCurse() {
return this.is(EnchantmenTypeTags.CURSE);
}

}
90 changes: 90 additions & 0 deletions src/main/java/org/spongepowered/api/tag/EnchantmenTypeTags.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* 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;

/**
* <!-- This file is automatically generated. Any manual changes will be overwritten. -->
*/
@SuppressWarnings("unused")
@RegistryScopes(scopes = RegistryScope.GAME)
public final class EnchantmenTypeTags {

public static final Tag<EnchantmentType> CURSE = EnchantmenTypeTags.key(ResourceKey.minecraft("curse"));

public static final Tag<EnchantmentType> DOUBLE_TRADE_PRICE = EnchantmenTypeTags.key(ResourceKey.minecraft("double_trade_price"));

public static final Tag<EnchantmentType> EXCLUSIVE_SET_ARMOR = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/armor"));

public static final Tag<EnchantmentType> EXCLUSIVE_SET_BOOTS = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/boots"));

public static final Tag<EnchantmentType> EXCLUSIVE_SET_BOW = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/bow"));

public static final Tag<EnchantmentType> EXCLUSIVE_SET_CROSSBOW = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/crossbow"));

public static final Tag<EnchantmentType> EXCLUSIVE_SET_DAMAGE = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/damage"));

public static final Tag<EnchantmentType> EXCLUSIVE_SET_MINING = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/mining"));

public static final Tag<EnchantmentType> EXCLUSIVE_SET_RIPTIDE = EnchantmenTypeTags.key(ResourceKey.minecraft("exclusive_set/riptide"));

public static final Tag<EnchantmentType> IN_ENCHANTING_TABLE = EnchantmenTypeTags.key(ResourceKey.minecraft("in_enchanting_table"));

public static final Tag<EnchantmentType> NON_TREASURE = EnchantmenTypeTags.key(ResourceKey.minecraft("non_treasure"));

public static final Tag<EnchantmentType> ON_MOB_SPAWN_EQUIPMENT = EnchantmenTypeTags.key(ResourceKey.minecraft("on_mob_spawn_equipment"));

public static final Tag<EnchantmentType> ON_RANDOM_LOOT = EnchantmenTypeTags.key(ResourceKey.minecraft("on_random_loot"));

public static final Tag<EnchantmentType> ON_TRADED_EQUIPMENT = EnchantmenTypeTags.key(ResourceKey.minecraft("on_traded_equipment"));

public static final Tag<EnchantmentType> PREVENTS_BEE_SPAWNS_WHEN_MINING = EnchantmenTypeTags.key(ResourceKey.minecraft("prevents_bee_spawns_when_mining"));

public static final Tag<EnchantmentType> PREVENTS_DECORATED_POT_SHATTERING = EnchantmenTypeTags.key(ResourceKey.minecraft("prevents_decorated_pot_shattering"));

public static final Tag<EnchantmentType> PREVENTS_ICE_MELTING = EnchantmenTypeTags.key(ResourceKey.minecraft("prevents_ice_melting"));

public static final Tag<EnchantmentType> PREVENTS_INFESTED_SPAWNS = EnchantmenTypeTags.key(ResourceKey.minecraft("prevents_infested_spawns"));

public static final Tag<EnchantmentType> SMELTS_LOOT = EnchantmenTypeTags.key(ResourceKey.minecraft("smelts_loot"));

public static final Tag<EnchantmentType> TOOLTIP_ORDER = EnchantmenTypeTags.key(ResourceKey.minecraft("tooltip_order"));

public static final Tag<EnchantmentType> TRADEABLE = EnchantmenTypeTags.key(ResourceKey.minecraft("tradeable"));

public static final Tag<EnchantmentType> TREASURE = EnchantmenTypeTags.key(ResourceKey.minecraft("treasure"));

private EnchantmenTypeTags() {
}

private static Tag<EnchantmentType> key(final ResourceKey key) {
return Tag.of(RegistryTypes.ENCHANTMENT_TYPE, key);
}
}

0 comments on commit 0a98172

Please sign in to comment.