From 5b7dab89e89b5f6532c77afc76262fe574f6b3c6 Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Fri, 28 Mar 2025 04:25:00 +0300 Subject: [PATCH 01/10] delete Keys.APPLICABLE_POTION_EFFECTS --- src/main/java/org/spongepowered/api/data/Keys.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index fde30f367e..350f100f99 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -398,11 +398,6 @@ public final class Keys { */ public static final Key> ANGER_LEVEL = Keys.key(ResourceKey.sponge("anger_level"), Integer.class); - /** - * The set of {@link PotionEffect}s applied on use of an {@link ItemStack}. - */ - public static final Key> APPLICABLE_POTION_EFFECTS = Keys.weightedKey(ResourceKey.sponge("applicable_potion_effects"), PotionEffect.class); - /** * The enchantments applied to an {@link ItemStack}. * From 32a354bf270dbbae19d8eb69d79aef16e5b45474 Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Fri, 28 Mar 2025 04:34:20 +0300 Subject: [PATCH 02/10] make PotionEffectType Taggable --- .../org/spongepowered/api/effect/potion/PotionEffectType.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/spongepowered/api/effect/potion/PotionEffectType.java b/src/main/java/org/spongepowered/api/effect/potion/PotionEffectType.java index 7179f435d2..300f888df1 100644 --- a/src/main/java/org/spongepowered/api/effect/potion/PotionEffectType.java +++ b/src/main/java/org/spongepowered/api/effect/potion/PotionEffectType.java @@ -25,14 +25,14 @@ package org.spongepowered.api.effect.potion; import net.kyori.adventure.text.ComponentLike; -import org.spongepowered.api.registry.DefaultedRegistryValue; +import org.spongepowered.api.tag.Taggable; import org.spongepowered.api.util.annotation.CatalogedBy; /** * Represents a possible type of {@link PotionEffect}. */ @CatalogedBy(PotionEffectTypes.class) -public interface PotionEffectType extends DefaultedRegistryValue, ComponentLike { +public interface PotionEffectType extends Taggable, ComponentLike { /** * Gets whether this potion effect is applied instantly or over time. From a9db08d65101f04b126433dbdae869f2f29c3db5 Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Fri, 28 Mar 2025 16:01:26 +0300 Subject: [PATCH 03/10] Add ConsumeEffects --- .../java/org/spongepowered/api/data/Keys.java | 6 + .../api/data/type/ConsumeEffect.java | 224 ++++++++++++++++++ .../api/data/type/ConsumeEffectType.java | 35 +++ .../api/data/type/ConsumeEffectTypes.java | 63 +++++ .../api/registry/RegistryTypes.java | 3 + 5 files changed, 331 insertions(+) create mode 100644 src/main/java/org/spongepowered/api/data/type/ConsumeEffect.java create mode 100644 src/main/java/org/spongepowered/api/data/type/ConsumeEffectType.java create mode 100644 src/main/java/org/spongepowered/api/data/type/ConsumeEffectTypes.java diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 350f100f99..e8c48b07b0 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -61,6 +61,7 @@ import org.spongepowered.api.data.type.CatType; import org.spongepowered.api.data.type.ChestAttachmentType; import org.spongepowered.api.data.type.ComparatorMode; +import org.spongepowered.api.data.type.ConsumeEffect; import org.spongepowered.api.data.type.DoorHinge; import org.spongepowered.api.data.type.DripstoneSegment; import org.spongepowered.api.data.type.DyeColor; @@ -772,6 +773,11 @@ public final class Keys { */ public static final Key> CONNECTED_DIRECTIONS = Keys.setKey(ResourceKey.sponge("connected_directions"), Direction.class); + /** + * The {@link ConsumeEffect}s an {@link ItemStack} will apply when consumed. + */ + public static final Key> CONSUME_EFFECTS = Keys.listKey(ResourceKey.sponge("consume_effects"), ConsumeEffect.class); + /** * The container {@link ItemType} of an {@link ItemStack}. * e.g. {@link ItemTypes#BUCKET} for a {@link ItemTypes#WATER_BUCKET} stack. diff --git a/src/main/java/org/spongepowered/api/data/type/ConsumeEffect.java b/src/main/java/org/spongepowered/api/data/type/ConsumeEffect.java new file mode 100644 index 0000000000..b45455e4f1 --- /dev/null +++ b/src/main/java/org/spongepowered/api/data/type/ConsumeEffect.java @@ -0,0 +1,224 @@ +/* + * 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.data.type; + +import org.spongepowered.api.Sponge; +import org.spongepowered.api.effect.potion.PotionEffect; +import org.spongepowered.api.effect.potion.PotionEffectType; +import org.spongepowered.api.effect.sound.SoundType; +import org.spongepowered.api.entity.living.Living; +import org.spongepowered.api.item.inventory.ItemStack; +import org.spongepowered.api.item.inventory.ItemStackLike; +import org.spongepowered.api.tag.Tag; +import org.spongepowered.api.world.World; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +/** + * Represents an effect that can be applied on {@link ItemStack} consumption. + */ +public interface ConsumeEffect { + + static ApplyEffects applyEffects(final Collection effects) { + return ConsumeEffect.applyEffects(1.0D, effects); + } + + static ApplyEffects applyEffects(final PotionEffect... effects) { + return ConsumeEffect.applyEffects(1.0D, effects); + } + + static ApplyEffects applyEffects(final double chance, final Collection effects) { + return ConsumeEffect.factory().applyEffects(chance, List.copyOf(effects)); + } + + static ApplyEffects applyEffects(final double chance, final PotionEffect... effects) { + return ConsumeEffect.factory().applyEffects(chance, List.of(effects)); + } + + static RemoveEffects removeEffects(final Collection effectTypes) { + return ConsumeEffect.factory().removeEffects(Set.copyOf(effectTypes)); + } + + static RemoveEffects removeEffects(final PotionEffectType... effectTypes) { + return ConsumeEffect.factory().removeEffects(Set.of(effectTypes)); + } + + @SafeVarargs + static RemoveEffects removeEffects(final Supplier... effectTypes) { + return ConsumeEffect.factory().removeEffects(Arrays.stream(effectTypes).map(Supplier::get).collect(Collectors.toSet())); + } + + static RemoveEffects removeEffects(final Tag effectTypeTag) { + return ConsumeEffect.factory().removeEffects(effectTypeTag); + } + + static ClearEffects clearEffects() { + return ConsumeEffect.factory().clearEffects(); + } + + static PlaySound playSound(final SoundType soundType) { + return ConsumeEffect.factory().playSound(soundType); + } + + static PlaySound playSound(final Supplier soundType) { + return ConsumeEffect.factory().playSound(soundType.get()); + } + + static TeleportRandomly teleportRandomly(final double distance) { + return ConsumeEffect.factory().teleportRandomly(distance); + } + + private static Factory factory() { + return Sponge.game().factoryProvider().provide(Factory.class); + } + + /** + * Returns the type of this effect. + * @return The type of this effect + */ + ConsumeEffectType type(); + + /** + * Tries to apply this effect and returns whether it was successfully applied. + * The definition of success is purely left up to the implementation. + * + * @param world The world to apply effect in + * @param entity The entity to apply effect to + * @param stack The item to apply effect with + * @return true if effect was successfully applied + */ + boolean apply(World world, Living entity, ItemStackLike stack); + + /** + * Applies this effect with {@link ItemStack#empty()}. + * + * @param world The world to apply effect in + * @param entity The entity to apply effect to + * @return true if effect was successfully applied + * @see #apply(World, Living, ItemStackLike) + */ + default boolean apply(final World world, final Living entity) { + return this.apply(world, entity, ItemStack.empty()); + } + + /** + * Applies this effect with {@link Living#world()}. + * + * @param entity The entity to apply effect to + * @param stack The item to apply effect with + * @return true if effect was successfully applied + * @see #apply(World, Living, ItemStackLike) + */ + default boolean apply(final Living entity, final ItemStackLike stack) { + return this.apply(entity.world(), entity, stack); + } + + /** + * Applies this effect with {@link Living#world()} and {@link ItemStack#empty()}. + * + * @param entity The entity to apply effect to + * @return true if effect was successfully applied + * @see #apply(World, Living, ItemStackLike) + */ + default boolean apply(final Living entity) { + return this.apply(entity.world(), entity, ItemStack.empty()); + } + + /** + * Applies {@link PotionEffect}s with chance. + */ + interface ApplyEffects extends ConsumeEffect { + /** + * Returns the probability for effects to be applied. + * @return The probability for effects to be applied + */ + double chance(); + + /** + * Returns {@link PotionEffect}s that will be applied. + * @return {@link PotionEffect}s that will be applied + */ + List effects(); + } + + /** + * Removes {@link PotionEffect}s with matching {@link PotionEffectType}s. + */ + interface RemoveEffects extends ConsumeEffect { + /** + * Returns {@link PotionEffectType}s that will be removed. + * @return {@link PotionEffectType}s that will be removed + */ + Set effectTypes(); + } + + /** + * Clears all {@link PotionEffect}s. + */ + interface ClearEffects extends ConsumeEffect { + } + + /** + * Plays {@link SoundType}. + */ + interface PlaySound extends ConsumeEffect { + /** + * Returns the consumption {@link SoundType}. + * @return The consumption {@link SoundType} + */ + SoundType soundType(); + } + + /** + * Teleports randomly within maximum distance. + */ + interface TeleportRandomly extends ConsumeEffect { + /** + * Returns the maximum distance entity can be teleported. + * @return The maximum distance entity can be teleported + */ + double distance(); + } + + interface Factory { + + ApplyEffects applyEffects(double chance, List effects); + + RemoveEffects removeEffects(Set effectTypes); + + RemoveEffects removeEffects(Tag effectTypeTag); + + ClearEffects clearEffects(); + + PlaySound playSound(SoundType soundType); + + TeleportRandomly teleportRandomly(double distance); + } +} diff --git a/src/main/java/org/spongepowered/api/data/type/ConsumeEffectType.java b/src/main/java/org/spongepowered/api/data/type/ConsumeEffectType.java new file mode 100644 index 0000000000..14626f225a --- /dev/null +++ b/src/main/java/org/spongepowered/api/data/type/ConsumeEffectType.java @@ -0,0 +1,35 @@ +/* + * 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.data.type; + +import org.spongepowered.api.registry.DefaultedRegistryValue; +import org.spongepowered.api.util.annotation.CatalogedBy; + +/** + * Represents a possible type of {@link ConsumeEffect}. + */ +@CatalogedBy(ConsumeEffectTypes.class) +public interface ConsumeEffectType extends DefaultedRegistryValue { +} diff --git a/src/main/java/org/spongepowered/api/data/type/ConsumeEffectTypes.java b/src/main/java/org/spongepowered/api/data/type/ConsumeEffectTypes.java new file mode 100644 index 0000000000..ae683355f0 --- /dev/null +++ b/src/main/java/org/spongepowered/api/data/type/ConsumeEffectTypes.java @@ -0,0 +1,63 @@ +/* + * 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.data.type; + +import org.spongepowered.api.ResourceKey; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.registry.DefaultedRegistryReference; +import org.spongepowered.api.registry.Registry; +import org.spongepowered.api.registry.RegistryKey; +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 ConsumeEffectTypes { + + public static final DefaultedRegistryReference APPLY_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("apply_effects")); + + public static final DefaultedRegistryReference CLEAR_ALL_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("clear_all_effects")); + + public static final DefaultedRegistryReference PLAY_SOUND = ConsumeEffectTypes.key(ResourceKey.minecraft("play_sound")); + + public static final DefaultedRegistryReference REMOVE_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("remove_effects")); + + public static final DefaultedRegistryReference TELEPORT_RANDOMLY = ConsumeEffectTypes.key(ResourceKey.minecraft("teleport_randomly")); + + private ConsumeEffectTypes() { + } + + public static Registry registry() { + return Sponge.game().registry(RegistryTypes.CONSUME_EFFECT_TYPE); + } + + private static DefaultedRegistryReference key(final ResourceKey location) { + return RegistryKey.of(RegistryTypes.CONSUME_EFFECT_TYPE, location).asDefaultedReference(Sponge::game); + } +} diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index 08ea7298d3..6989c7e688 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -56,6 +56,7 @@ import org.spongepowered.api.data.type.CatType; import org.spongepowered.api.data.type.ChestAttachmentType; import org.spongepowered.api.data.type.ComparatorMode; +import org.spongepowered.api.data.type.ConsumeEffectType; import org.spongepowered.api.data.type.DoorHinge; import org.spongepowered.api.data.type.DripstoneSegment; import org.spongepowered.api.data.type.DyeColor; @@ -226,6 +227,8 @@ public final class RegistryTypes { public static final DefaultedRegistryType CHUNK_STATE = RegistryTypes.minecraftKeyInGame("chunk_status"); + public static final DefaultedRegistryType CONSUME_EFFECT_TYPE = RegistryTypes.minecraftKeyInGame("consume_effect_type"); + public static final DefaultedRegistryType CONTAINER_TYPE = RegistryTypes.minecraftKeyInGame("menu"); public static final DefaultedRegistryType DENSITY_FUNCTION = RegistryTypes.minecraftKeyInServer("worldgen/density_function"); From c0b74b5a4aee6bdc5a535dc9c75b4fa5189e929a Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Fri, 28 Mar 2025 17:58:42 +0300 Subject: [PATCH 04/10] fix some registries having not defaulted type --- .../java/org/spongepowered/api/registry/RegistryTypes.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index 6989c7e688..c209736cd2 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -376,7 +376,7 @@ public final class RegistryTypes { public static final DefaultedRegistryType EQUIPMENT_TYPE = RegistryTypes.spongeKeyInGame("equipment_type"); - public static final RegistryType EXPLOSION_BLOCK_INTERACTION = RegistryTypes.spongeKeyInGame("explosion_block_interaction"); + public static final DefaultedRegistryType EXPLOSION_BLOCK_INTERACTION = RegistryTypes.spongeKeyInGame("explosion_block_interaction"); public static final DefaultedRegistryType FIREWORK_SHAPE = RegistryTypes.spongeKeyInGame("firework_shape"); @@ -520,7 +520,7 @@ public final class RegistryTypes { public static final DefaultedRegistryType TILT = RegistryTypes.spongeKeyInGame("tilt"); - public static final RegistryType VAULT_STATE = RegistryTypes.spongeKeyInGame("vault_state"); + public static final DefaultedRegistryType VAULT_STATE = RegistryTypes.spongeKeyInGame("vault_state"); public static final DefaultedRegistryType VISIBILITY = RegistryTypes.spongeKeyInGame("visibility"); From a0ef5e602d39d72ff4bf5a292e5e07effb0c50e5 Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Mon, 31 Mar 2025 00:27:12 +0300 Subject: [PATCH 05/10] add Keys.DEATH_PROTECTION_EFFECTS --- src/main/java/org/spongepowered/api/data/Keys.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index e8c48b07b0..87f7c1240f 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -928,6 +928,11 @@ public final class Keys { */ public static final Key> DAMAGE_PER_BLOCK = Keys.key(ResourceKey.sponge("damage_per_block"), Double.class); + /** + * The {@link ConsumeEffect}s an {@link ItemStack} will apply on death. + */ + public static final Key> DEATH_PROTECTION_EFFECTS = Keys.listKey(ResourceKey.sponge("death_protection_effects"), ConsumeEffect.class); + /** * The distance at which a {@link BlockState} will decay. * This usually applies to leaves, for example {@link BlockTypes#OAK_LEAVES}. From b4ec15e3eeabf9fbd658211c6d464612c6078915 Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Mon, 31 Mar 2025 05:07:44 +0300 Subject: [PATCH 06/10] rename ConsumeEffect -> ItemActionEffect --- .../java/org/spongepowered/api/data/Keys.java | 10 ++--- .../api/data/type/ConsumeEffectTypes.java | 18 ++++----- ...nsumeEffect.java => ItemActionEffect.java} | 38 +++++++++---------- ...ectType.java => ItemActionEffectType.java} | 4 +- .../api/registry/RegistryTypes.java | 4 +- 5 files changed, 37 insertions(+), 37 deletions(-) rename src/main/java/org/spongepowered/api/data/type/{ConsumeEffect.java => ItemActionEffect.java} (84%) rename src/main/java/org/spongepowered/api/data/type/{ConsumeEffectType.java => ItemActionEffectType.java} (91%) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 87f7c1240f..c39c4aac15 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -61,7 +61,7 @@ import org.spongepowered.api.data.type.CatType; import org.spongepowered.api.data.type.ChestAttachmentType; import org.spongepowered.api.data.type.ComparatorMode; -import org.spongepowered.api.data.type.ConsumeEffect; +import org.spongepowered.api.data.type.ItemActionEffect; import org.spongepowered.api.data.type.DoorHinge; import org.spongepowered.api.data.type.DripstoneSegment; import org.spongepowered.api.data.type.DyeColor; @@ -774,9 +774,9 @@ public final class Keys { public static final Key> CONNECTED_DIRECTIONS = Keys.setKey(ResourceKey.sponge("connected_directions"), Direction.class); /** - * The {@link ConsumeEffect}s an {@link ItemStack} will apply when consumed. + * The {@link ItemActionEffect}s an {@link ItemStack} will apply when consumed. */ - public static final Key> CONSUME_EFFECTS = Keys.listKey(ResourceKey.sponge("consume_effects"), ConsumeEffect.class); + public static final Key> CONSUME_EFFECTS = Keys.listKey(ResourceKey.sponge("consume_effects"), ItemActionEffect.class); /** * The container {@link ItemType} of an {@link ItemStack}. @@ -929,9 +929,9 @@ public final class Keys { public static final Key> DAMAGE_PER_BLOCK = Keys.key(ResourceKey.sponge("damage_per_block"), Double.class); /** - * The {@link ConsumeEffect}s an {@link ItemStack} will apply on death. + * The {@link ItemActionEffect}s an {@link ItemStack} will apply on death. */ - public static final Key> DEATH_PROTECTION_EFFECTS = Keys.listKey(ResourceKey.sponge("death_protection_effects"), ConsumeEffect.class); + public static final Key> DEATH_PROTECTION_EFFECTS = Keys.listKey(ResourceKey.sponge("death_protection_effects"), ItemActionEffect.class); /** * The distance at which a {@link BlockState} will decay. diff --git a/src/main/java/org/spongepowered/api/data/type/ConsumeEffectTypes.java b/src/main/java/org/spongepowered/api/data/type/ConsumeEffectTypes.java index ae683355f0..a9aeb23b2d 100644 --- a/src/main/java/org/spongepowered/api/data/type/ConsumeEffectTypes.java +++ b/src/main/java/org/spongepowered/api/data/type/ConsumeEffectTypes.java @@ -40,24 +40,24 @@ @RegistryScopes(scopes = RegistryScope.GAME) public final class ConsumeEffectTypes { - public static final DefaultedRegistryReference APPLY_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("apply_effects")); + public static final DefaultedRegistryReference APPLY_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("apply_effects")); - public static final DefaultedRegistryReference CLEAR_ALL_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("clear_all_effects")); + public static final DefaultedRegistryReference CLEAR_ALL_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("clear_all_effects")); - public static final DefaultedRegistryReference PLAY_SOUND = ConsumeEffectTypes.key(ResourceKey.minecraft("play_sound")); + public static final DefaultedRegistryReference PLAY_SOUND = ConsumeEffectTypes.key(ResourceKey.minecraft("play_sound")); - public static final DefaultedRegistryReference REMOVE_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("remove_effects")); + public static final DefaultedRegistryReference REMOVE_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("remove_effects")); - public static final DefaultedRegistryReference TELEPORT_RANDOMLY = ConsumeEffectTypes.key(ResourceKey.minecraft("teleport_randomly")); + public static final DefaultedRegistryReference TELEPORT_RANDOMLY = ConsumeEffectTypes.key(ResourceKey.minecraft("teleport_randomly")); private ConsumeEffectTypes() { } - public static Registry registry() { - return Sponge.game().registry(RegistryTypes.CONSUME_EFFECT_TYPE); + public static Registry registry() { + return Sponge.game().registry(RegistryTypes.ITEM_ACTION_EFFECT_TYPE); } - private static DefaultedRegistryReference key(final ResourceKey location) { - return RegistryKey.of(RegistryTypes.CONSUME_EFFECT_TYPE, location).asDefaultedReference(Sponge::game); + private static DefaultedRegistryReference key(final ResourceKey location) { + return RegistryKey.of(RegistryTypes.ITEM_ACTION_EFFECT_TYPE, location).asDefaultedReference(Sponge::game); } } diff --git a/src/main/java/org/spongepowered/api/data/type/ConsumeEffect.java b/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java similarity index 84% rename from src/main/java/org/spongepowered/api/data/type/ConsumeEffect.java rename to src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java index b45455e4f1..7a7e97caa7 100644 --- a/src/main/java/org/spongepowered/api/data/type/ConsumeEffect.java +++ b/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java @@ -44,55 +44,55 @@ /** * Represents an effect that can be applied on {@link ItemStack} consumption. */ -public interface ConsumeEffect { +public interface ItemActionEffect { static ApplyEffects applyEffects(final Collection effects) { - return ConsumeEffect.applyEffects(1.0D, effects); + return ItemActionEffect.applyEffects(1.0D, effects); } static ApplyEffects applyEffects(final PotionEffect... effects) { - return ConsumeEffect.applyEffects(1.0D, effects); + return ItemActionEffect.applyEffects(1.0D, effects); } static ApplyEffects applyEffects(final double chance, final Collection effects) { - return ConsumeEffect.factory().applyEffects(chance, List.copyOf(effects)); + return ItemActionEffect.factory().applyEffects(chance, List.copyOf(effects)); } static ApplyEffects applyEffects(final double chance, final PotionEffect... effects) { - return ConsumeEffect.factory().applyEffects(chance, List.of(effects)); + return ItemActionEffect.factory().applyEffects(chance, List.of(effects)); } static RemoveEffects removeEffects(final Collection effectTypes) { - return ConsumeEffect.factory().removeEffects(Set.copyOf(effectTypes)); + return ItemActionEffect.factory().removeEffects(Set.copyOf(effectTypes)); } static RemoveEffects removeEffects(final PotionEffectType... effectTypes) { - return ConsumeEffect.factory().removeEffects(Set.of(effectTypes)); + return ItemActionEffect.factory().removeEffects(Set.of(effectTypes)); } @SafeVarargs static RemoveEffects removeEffects(final Supplier... effectTypes) { - return ConsumeEffect.factory().removeEffects(Arrays.stream(effectTypes).map(Supplier::get).collect(Collectors.toSet())); + return ItemActionEffect.factory().removeEffects(Arrays.stream(effectTypes).map(Supplier::get).collect(Collectors.toSet())); } static RemoveEffects removeEffects(final Tag effectTypeTag) { - return ConsumeEffect.factory().removeEffects(effectTypeTag); + return ItemActionEffect.factory().removeEffects(effectTypeTag); } static ClearEffects clearEffects() { - return ConsumeEffect.factory().clearEffects(); + return ItemActionEffect.factory().clearEffects(); } static PlaySound playSound(final SoundType soundType) { - return ConsumeEffect.factory().playSound(soundType); + return ItemActionEffect.factory().playSound(soundType); } static PlaySound playSound(final Supplier soundType) { - return ConsumeEffect.factory().playSound(soundType.get()); + return ItemActionEffect.factory().playSound(soundType.get()); } static TeleportRandomly teleportRandomly(final double distance) { - return ConsumeEffect.factory().teleportRandomly(distance); + return ItemActionEffect.factory().teleportRandomly(distance); } private static Factory factory() { @@ -103,7 +103,7 @@ private static Factory factory() { * Returns the type of this effect. * @return The type of this effect */ - ConsumeEffectType type(); + ItemActionEffectType type(); /** * Tries to apply this effect and returns whether it was successfully applied. @@ -154,7 +154,7 @@ default boolean apply(final Living entity) { /** * Applies {@link PotionEffect}s with chance. */ - interface ApplyEffects extends ConsumeEffect { + interface ApplyEffects extends ItemActionEffect { /** * Returns the probability for effects to be applied. * @return The probability for effects to be applied @@ -171,7 +171,7 @@ interface ApplyEffects extends ConsumeEffect { /** * Removes {@link PotionEffect}s with matching {@link PotionEffectType}s. */ - interface RemoveEffects extends ConsumeEffect { + interface RemoveEffects extends ItemActionEffect { /** * Returns {@link PotionEffectType}s that will be removed. * @return {@link PotionEffectType}s that will be removed @@ -182,13 +182,13 @@ interface RemoveEffects extends ConsumeEffect { /** * Clears all {@link PotionEffect}s. */ - interface ClearEffects extends ConsumeEffect { + interface ClearEffects extends ItemActionEffect { } /** * Plays {@link SoundType}. */ - interface PlaySound extends ConsumeEffect { + interface PlaySound extends ItemActionEffect { /** * Returns the consumption {@link SoundType}. * @return The consumption {@link SoundType} @@ -199,7 +199,7 @@ interface PlaySound extends ConsumeEffect { /** * Teleports randomly within maximum distance. */ - interface TeleportRandomly extends ConsumeEffect { + interface TeleportRandomly extends ItemActionEffect { /** * Returns the maximum distance entity can be teleported. * @return The maximum distance entity can be teleported diff --git a/src/main/java/org/spongepowered/api/data/type/ConsumeEffectType.java b/src/main/java/org/spongepowered/api/data/type/ItemActionEffectType.java similarity index 91% rename from src/main/java/org/spongepowered/api/data/type/ConsumeEffectType.java rename to src/main/java/org/spongepowered/api/data/type/ItemActionEffectType.java index 14626f225a..4eaba81b61 100644 --- a/src/main/java/org/spongepowered/api/data/type/ConsumeEffectType.java +++ b/src/main/java/org/spongepowered/api/data/type/ItemActionEffectType.java @@ -28,8 +28,8 @@ import org.spongepowered.api.util.annotation.CatalogedBy; /** - * Represents a possible type of {@link ConsumeEffect}. + * Represents a possible type of {@link ItemActionEffect}. */ @CatalogedBy(ConsumeEffectTypes.class) -public interface ConsumeEffectType extends DefaultedRegistryValue { +public interface ItemActionEffectType extends DefaultedRegistryValue { } diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index 709ff70ecb..add67277b2 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -56,7 +56,7 @@ import org.spongepowered.api.data.type.CatType; import org.spongepowered.api.data.type.ChestAttachmentType; import org.spongepowered.api.data.type.ComparatorMode; -import org.spongepowered.api.data.type.ConsumeEffectType; +import org.spongepowered.api.data.type.ItemActionEffectType; import org.spongepowered.api.data.type.DoorHinge; import org.spongepowered.api.data.type.DripstoneSegment; import org.spongepowered.api.data.type.DyeColor; @@ -227,7 +227,7 @@ public final class RegistryTypes { public static final DefaultedRegistryType CHUNK_STATE = RegistryTypes.minecraftKeyInGame("chunk_status"); - public static final DefaultedRegistryType CONSUME_EFFECT_TYPE = RegistryTypes.minecraftKeyInGame("consume_effect_type"); + public static final DefaultedRegistryType ITEM_ACTION_EFFECT_TYPE = RegistryTypes.minecraftKeyInGame("consume_effect_type"); public static final DefaultedRegistryType CONTAINER_TYPE = RegistryTypes.minecraftKeyInGame("menu"); From 24162feaf53a8b617b57ec3851e6cb62dbe7175d Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Mon, 31 Mar 2025 05:12:46 +0300 Subject: [PATCH 07/10] remove world arg for ItemActionEffect#apply --- .../api/data/type/ItemActionEffect.java | 31 ++----------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java b/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java index 7a7e97caa7..796a53b93a 100644 --- a/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java +++ b/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java @@ -109,46 +109,21 @@ private static Factory factory() { * Tries to apply this effect and returns whether it was successfully applied. * The definition of success is purely left up to the implementation. * - * @param world The world to apply effect in * @param entity The entity to apply effect to * @param stack The item to apply effect with * @return true if effect was successfully applied */ - boolean apply(World world, Living entity, ItemStackLike stack); + boolean apply(Living entity, ItemStackLike stack); /** * Applies this effect with {@link ItemStack#empty()}. * - * @param world The world to apply effect in * @param entity The entity to apply effect to * @return true if effect was successfully applied - * @see #apply(World, Living, ItemStackLike) - */ - default boolean apply(final World world, final Living entity) { - return this.apply(world, entity, ItemStack.empty()); - } - - /** - * Applies this effect with {@link Living#world()}. - * - * @param entity The entity to apply effect to - * @param stack The item to apply effect with - * @return true if effect was successfully applied - * @see #apply(World, Living, ItemStackLike) - */ - default boolean apply(final Living entity, final ItemStackLike stack) { - return this.apply(entity.world(), entity, stack); - } - - /** - * Applies this effect with {@link Living#world()} and {@link ItemStack#empty()}. - * - * @param entity The entity to apply effect to - * @return true if effect was successfully applied - * @see #apply(World, Living, ItemStackLike) + * @see #apply(Living, ItemStackLike) */ default boolean apply(final Living entity) { - return this.apply(entity.world(), entity, ItemStack.empty()); + return this.apply(entity, ItemStack.empty()); } /** From e0debb69677b4f60544bc4daa1e93c7bdd686b5c Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Mon, 31 Mar 2025 05:24:05 +0300 Subject: [PATCH 08/10] update ItemActionEffect docs --- src/main/java/org/spongepowered/api/data/Keys.java | 2 +- .../org/spongepowered/api/data/type/ItemActionEffect.java | 7 +++++-- .../java/org/spongepowered/api/registry/RegistryTypes.java | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index c39c4aac15..d26b568419 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -61,7 +61,6 @@ import org.spongepowered.api.data.type.CatType; import org.spongepowered.api.data.type.ChestAttachmentType; import org.spongepowered.api.data.type.ComparatorMode; -import org.spongepowered.api.data.type.ItemActionEffect; import org.spongepowered.api.data.type.DoorHinge; import org.spongepowered.api.data.type.DripstoneSegment; import org.spongepowered.api.data.type.DyeColor; @@ -71,6 +70,7 @@ import org.spongepowered.api.data.type.HorseColor; import org.spongepowered.api.data.type.HorseStyle; import org.spongepowered.api.data.type.InstrumentType; +import org.spongepowered.api.data.type.ItemActionEffect; import org.spongepowered.api.data.type.ItemTier; import org.spongepowered.api.data.type.LlamaType; import org.spongepowered.api.data.type.MatterType; diff --git a/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java b/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java index 796a53b93a..e81bf907b5 100644 --- a/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java +++ b/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java @@ -25,6 +25,7 @@ package org.spongepowered.api.data.type; import org.spongepowered.api.Sponge; +import org.spongepowered.api.data.Keys; import org.spongepowered.api.effect.potion.PotionEffect; import org.spongepowered.api.effect.potion.PotionEffectType; import org.spongepowered.api.effect.sound.SoundType; @@ -32,7 +33,6 @@ import org.spongepowered.api.item.inventory.ItemStack; import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.tag.Tag; -import org.spongepowered.api.world.World; import java.util.Arrays; import java.util.Collection; @@ -42,7 +42,10 @@ import java.util.stream.Collectors; /** - * Represents an effect that can be applied on {@link ItemStack} consumption. + * Represents an effect an {@link ItemStack} can apply after some actions. + * + * @see Keys#CONSUME_EFFECTS + * @see Keys#DEATH_PROTECTION_EFFECTS */ public interface ItemActionEffect { diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index add67277b2..c67e2c5ad6 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -56,7 +56,6 @@ import org.spongepowered.api.data.type.CatType; import org.spongepowered.api.data.type.ChestAttachmentType; import org.spongepowered.api.data.type.ComparatorMode; -import org.spongepowered.api.data.type.ItemActionEffectType; import org.spongepowered.api.data.type.DoorHinge; import org.spongepowered.api.data.type.DripstoneSegment; import org.spongepowered.api.data.type.DyeColor; @@ -67,6 +66,7 @@ import org.spongepowered.api.data.type.HorseColor; import org.spongepowered.api.data.type.HorseStyle; import org.spongepowered.api.data.type.InstrumentType; +import org.spongepowered.api.data.type.ItemActionEffectType; import org.spongepowered.api.data.type.ItemTier; import org.spongepowered.api.data.type.JigsawBlockOrientation; import org.spongepowered.api.data.type.LlamaType; From 0b3188cbce10514e492337293a0dad43c0ce8e47 Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Mon, 15 Sep 2025 19:35:05 +0300 Subject: [PATCH 09/10] rename to ItemAction --- .../java/org/spongepowered/api/data/Keys.java | 10 ++--- ...{ItemActionEffect.java => ItemAction.java} | 44 +++++++++---------- ...ionEffectType.java => ItemActionType.java} | 6 +-- ...eEffectTypes.java => ItemActionTypes.java} | 22 +++++----- .../api/registry/RegistryTypes.java | 4 +- 5 files changed, 43 insertions(+), 43 deletions(-) rename src/main/java/org/spongepowered/api/data/type/{ItemActionEffect.java => ItemAction.java} (79%) rename src/main/java/org/spongepowered/api/data/type/{ItemActionEffectType.java => ItemActionType.java} (89%) rename src/main/java/org/spongepowered/api/data/type/{ConsumeEffectTypes.java => ItemActionTypes.java} (63%) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index d26b568419..785ce2af6d 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -70,7 +70,7 @@ import org.spongepowered.api.data.type.HorseColor; import org.spongepowered.api.data.type.HorseStyle; import org.spongepowered.api.data.type.InstrumentType; -import org.spongepowered.api.data.type.ItemActionEffect; +import org.spongepowered.api.data.type.ItemAction; import org.spongepowered.api.data.type.ItemTier; import org.spongepowered.api.data.type.LlamaType; import org.spongepowered.api.data.type.MatterType; @@ -774,9 +774,9 @@ public final class Keys { public static final Key> CONNECTED_DIRECTIONS = Keys.setKey(ResourceKey.sponge("connected_directions"), Direction.class); /** - * The {@link ItemActionEffect}s an {@link ItemStack} will apply when consumed. + * The {@link ItemAction}s an {@link ItemStack} will apply when consumed. */ - public static final Key> CONSUME_EFFECTS = Keys.listKey(ResourceKey.sponge("consume_effects"), ItemActionEffect.class); + public static final Key> CONSUME_ACTIONS = Keys.listKey(ResourceKey.sponge("consume_effects"), ItemAction.class); /** * The container {@link ItemType} of an {@link ItemStack}. @@ -929,9 +929,9 @@ public final class Keys { public static final Key> DAMAGE_PER_BLOCK = Keys.key(ResourceKey.sponge("damage_per_block"), Double.class); /** - * The {@link ItemActionEffect}s an {@link ItemStack} will apply on death. + * The {@link ItemAction}s an {@link ItemStack} will apply on death. */ - public static final Key> DEATH_PROTECTION_EFFECTS = Keys.listKey(ResourceKey.sponge("death_protection_effects"), ItemActionEffect.class); + public static final Key> DEATH_PROTECTION_ACTIONS = Keys.listKey(ResourceKey.sponge("death_protection_effects"), ItemAction.class); /** * The distance at which a {@link BlockState} will decay. diff --git a/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java b/src/main/java/org/spongepowered/api/data/type/ItemAction.java similarity index 79% rename from src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java rename to src/main/java/org/spongepowered/api/data/type/ItemAction.java index e81bf907b5..2516dfaaf9 100644 --- a/src/main/java/org/spongepowered/api/data/type/ItemActionEffect.java +++ b/src/main/java/org/spongepowered/api/data/type/ItemAction.java @@ -42,60 +42,60 @@ import java.util.stream.Collectors; /** - * Represents an effect an {@link ItemStack} can apply after some actions. + * Represents an action an {@link ItemStack} can apply to {@link Living} in different circumstances. * - * @see Keys#CONSUME_EFFECTS - * @see Keys#DEATH_PROTECTION_EFFECTS + * @see Keys#CONSUME_ACTIONS + * @see Keys#DEATH_PROTECTION_ACTIONS */ -public interface ItemActionEffect { +public interface ItemAction { static ApplyEffects applyEffects(final Collection effects) { - return ItemActionEffect.applyEffects(1.0D, effects); + return ItemAction.applyEffects(1.0D, effects); } static ApplyEffects applyEffects(final PotionEffect... effects) { - return ItemActionEffect.applyEffects(1.0D, effects); + return ItemAction.applyEffects(1.0D, effects); } static ApplyEffects applyEffects(final double chance, final Collection effects) { - return ItemActionEffect.factory().applyEffects(chance, List.copyOf(effects)); + return ItemAction.factory().applyEffects(chance, List.copyOf(effects)); } static ApplyEffects applyEffects(final double chance, final PotionEffect... effects) { - return ItemActionEffect.factory().applyEffects(chance, List.of(effects)); + return ItemAction.factory().applyEffects(chance, List.of(effects)); } static RemoveEffects removeEffects(final Collection effectTypes) { - return ItemActionEffect.factory().removeEffects(Set.copyOf(effectTypes)); + return ItemAction.factory().removeEffects(Set.copyOf(effectTypes)); } static RemoveEffects removeEffects(final PotionEffectType... effectTypes) { - return ItemActionEffect.factory().removeEffects(Set.of(effectTypes)); + return ItemAction.factory().removeEffects(Set.of(effectTypes)); } @SafeVarargs static RemoveEffects removeEffects(final Supplier... effectTypes) { - return ItemActionEffect.factory().removeEffects(Arrays.stream(effectTypes).map(Supplier::get).collect(Collectors.toSet())); + return ItemAction.factory().removeEffects(Arrays.stream(effectTypes).map(Supplier::get).collect(Collectors.toSet())); } static RemoveEffects removeEffects(final Tag effectTypeTag) { - return ItemActionEffect.factory().removeEffects(effectTypeTag); + return ItemAction.factory().removeEffects(effectTypeTag); } static ClearEffects clearEffects() { - return ItemActionEffect.factory().clearEffects(); + return ItemAction.factory().clearEffects(); } static PlaySound playSound(final SoundType soundType) { - return ItemActionEffect.factory().playSound(soundType); + return ItemAction.factory().playSound(soundType); } static PlaySound playSound(final Supplier soundType) { - return ItemActionEffect.factory().playSound(soundType.get()); + return ItemAction.factory().playSound(soundType.get()); } static TeleportRandomly teleportRandomly(final double distance) { - return ItemActionEffect.factory().teleportRandomly(distance); + return ItemAction.factory().teleportRandomly(distance); } private static Factory factory() { @@ -106,7 +106,7 @@ private static Factory factory() { * Returns the type of this effect. * @return The type of this effect */ - ItemActionEffectType type(); + ItemActionType type(); /** * Tries to apply this effect and returns whether it was successfully applied. @@ -132,7 +132,7 @@ default boolean apply(final Living entity) { /** * Applies {@link PotionEffect}s with chance. */ - interface ApplyEffects extends ItemActionEffect { + interface ApplyEffects extends ItemAction { /** * Returns the probability for effects to be applied. * @return The probability for effects to be applied @@ -149,7 +149,7 @@ interface ApplyEffects extends ItemActionEffect { /** * Removes {@link PotionEffect}s with matching {@link PotionEffectType}s. */ - interface RemoveEffects extends ItemActionEffect { + interface RemoveEffects extends ItemAction { /** * Returns {@link PotionEffectType}s that will be removed. * @return {@link PotionEffectType}s that will be removed @@ -160,13 +160,13 @@ interface RemoveEffects extends ItemActionEffect { /** * Clears all {@link PotionEffect}s. */ - interface ClearEffects extends ItemActionEffect { + interface ClearEffects extends ItemAction { } /** * Plays {@link SoundType}. */ - interface PlaySound extends ItemActionEffect { + interface PlaySound extends ItemAction { /** * Returns the consumption {@link SoundType}. * @return The consumption {@link SoundType} @@ -177,7 +177,7 @@ interface PlaySound extends ItemActionEffect { /** * Teleports randomly within maximum distance. */ - interface TeleportRandomly extends ItemActionEffect { + interface TeleportRandomly extends ItemAction { /** * Returns the maximum distance entity can be teleported. * @return The maximum distance entity can be teleported diff --git a/src/main/java/org/spongepowered/api/data/type/ItemActionEffectType.java b/src/main/java/org/spongepowered/api/data/type/ItemActionType.java similarity index 89% rename from src/main/java/org/spongepowered/api/data/type/ItemActionEffectType.java rename to src/main/java/org/spongepowered/api/data/type/ItemActionType.java index 4eaba81b61..16d0bfcae8 100644 --- a/src/main/java/org/spongepowered/api/data/type/ItemActionEffectType.java +++ b/src/main/java/org/spongepowered/api/data/type/ItemActionType.java @@ -28,8 +28,8 @@ import org.spongepowered.api.util.annotation.CatalogedBy; /** - * Represents a possible type of {@link ItemActionEffect}. + * Represents a possible type of {@link ItemAction}. */ -@CatalogedBy(ConsumeEffectTypes.class) -public interface ItemActionEffectType extends DefaultedRegistryValue { +@CatalogedBy(ItemActionTypes.class) +public interface ItemActionType extends DefaultedRegistryValue { } diff --git a/src/main/java/org/spongepowered/api/data/type/ConsumeEffectTypes.java b/src/main/java/org/spongepowered/api/data/type/ItemActionTypes.java similarity index 63% rename from src/main/java/org/spongepowered/api/data/type/ConsumeEffectTypes.java rename to src/main/java/org/spongepowered/api/data/type/ItemActionTypes.java index a9aeb23b2d..e01c637e80 100644 --- a/src/main/java/org/spongepowered/api/data/type/ConsumeEffectTypes.java +++ b/src/main/java/org/spongepowered/api/data/type/ItemActionTypes.java @@ -38,26 +38,26 @@ */ @SuppressWarnings("unused") @RegistryScopes(scopes = RegistryScope.GAME) -public final class ConsumeEffectTypes { +public final class ItemActionTypes { - public static final DefaultedRegistryReference APPLY_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("apply_effects")); + public static final DefaultedRegistryReference APPLY_EFFECTS = ItemActionTypes.key(ResourceKey.minecraft("apply_effects")); - public static final DefaultedRegistryReference CLEAR_ALL_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("clear_all_effects")); + public static final DefaultedRegistryReference CLEAR_ALL_EFFECTS = ItemActionTypes.key(ResourceKey.minecraft("clear_all_effects")); - public static final DefaultedRegistryReference PLAY_SOUND = ConsumeEffectTypes.key(ResourceKey.minecraft("play_sound")); + public static final DefaultedRegistryReference PLAY_SOUND = ItemActionTypes.key(ResourceKey.minecraft("play_sound")); - public static final DefaultedRegistryReference REMOVE_EFFECTS = ConsumeEffectTypes.key(ResourceKey.minecraft("remove_effects")); + public static final DefaultedRegistryReference REMOVE_EFFECTS = ItemActionTypes.key(ResourceKey.minecraft("remove_effects")); - public static final DefaultedRegistryReference TELEPORT_RANDOMLY = ConsumeEffectTypes.key(ResourceKey.minecraft("teleport_randomly")); + public static final DefaultedRegistryReference TELEPORT_RANDOMLY = ItemActionTypes.key(ResourceKey.minecraft("teleport_randomly")); - private ConsumeEffectTypes() { + private ItemActionTypes() { } - public static Registry registry() { - return Sponge.game().registry(RegistryTypes.ITEM_ACTION_EFFECT_TYPE); + public static Registry registry() { + return Sponge.game().registry(RegistryTypes.ITEM_ACTION_TYPE); } - private static DefaultedRegistryReference key(final ResourceKey location) { - return RegistryKey.of(RegistryTypes.ITEM_ACTION_EFFECT_TYPE, location).asDefaultedReference(Sponge::game); + private static DefaultedRegistryReference key(final ResourceKey location) { + return RegistryKey.of(RegistryTypes.ITEM_ACTION_TYPE, location).asDefaultedReference(Sponge::game); } } diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index c67e2c5ad6..fc5bbe6709 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -66,7 +66,7 @@ import org.spongepowered.api.data.type.HorseColor; import org.spongepowered.api.data.type.HorseStyle; import org.spongepowered.api.data.type.InstrumentType; -import org.spongepowered.api.data.type.ItemActionEffectType; +import org.spongepowered.api.data.type.ItemActionType; import org.spongepowered.api.data.type.ItemTier; import org.spongepowered.api.data.type.JigsawBlockOrientation; import org.spongepowered.api.data.type.LlamaType; @@ -227,7 +227,7 @@ public final class RegistryTypes { public static final DefaultedRegistryType CHUNK_STATE = RegistryTypes.minecraftKeyInGame("chunk_status"); - public static final DefaultedRegistryType ITEM_ACTION_EFFECT_TYPE = RegistryTypes.minecraftKeyInGame("consume_effect_type"); + public static final DefaultedRegistryType ITEM_ACTION_TYPE = RegistryTypes.minecraftKeyInGame("consume_effect_type"); public static final DefaultedRegistryType CONTAINER_TYPE = RegistryTypes.minecraftKeyInGame("menu"); From 60cc9274b7e7d14a9b54bafdfd243658bc13ee51 Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Mon, 15 Sep 2025 21:33:59 +0300 Subject: [PATCH 10/10] Revert "delete Keys.APPLICABLE_POTION_EFFECTS" This reverts commit 5b7dab89e89b5f6532c77afc76262fe574f6b3c6. --- src/main/java/org/spongepowered/api/data/Keys.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 785ce2af6d..fbe757ed12 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -399,6 +399,11 @@ public final class Keys { */ public static final Key> ANGER_LEVEL = Keys.key(ResourceKey.sponge("anger_level"), Integer.class); + /** + * The set of {@link PotionEffect}s applied on use of an {@link ItemStack}. + */ + public static final Key> APPLICABLE_POTION_EFFECTS = Keys.weightedKey(ResourceKey.sponge("applicable_potion_effects"), PotionEffect.class); + /** * The enchantments applied to an {@link ItemStack}. *