diff --git a/src/main/java/dev/enjarai/trickster/Trickster.java b/src/main/java/dev/enjarai/trickster/Trickster.java index d3dd3c7d..39c9d0bd 100644 --- a/src/main/java/dev/enjarai/trickster/Trickster.java +++ b/src/main/java/dev/enjarai/trickster/Trickster.java @@ -60,7 +60,7 @@ public void onInitialize() { PlayerBlockBreakEvents.BEFORE.register((world, player, pos, state, blockEntity) -> { if (player instanceof ServerPlayerEntity serverPlayer) - ItemTriggerHelper.triggerMainHand(serverPlayer, VectorFragment.of(pos)); + ItemTriggerHelper.triggerMainHand(serverPlayer, false, VectorFragment.of(pos)); else return true; var newState = world.getBlockState(pos); diff --git a/src/main/java/dev/enjarai/trickster/item/ModItems.java b/src/main/java/dev/enjarai/trickster/item/ModItems.java index 59c2039c..10253138 100644 --- a/src/main/java/dev/enjarai/trickster/item/ModItems.java +++ b/src/main/java/dev/enjarai/trickster/item/ModItems.java @@ -7,8 +7,6 @@ import io.wispforest.lavender.book.LavenderBookItem; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.minecraft.block.Block; -import net.minecraft.component.DataComponentTypes; -import net.minecraft.component.type.ContainerComponent; import net.minecraft.component.type.FoodComponent; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; @@ -18,7 +16,6 @@ import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; import net.minecraft.text.Text; -import net.minecraft.util.collection.DefaultedList; import java.util.List; import java.util.Optional; @@ -64,6 +61,7 @@ public class ModItems { // public static final TagKey IMMUTABLE_SPELL_HOLDERS = TagKey.of(RegistryKeys.ITEM, Trickster.id("immutable_spell_holders")); public static final TagKey SPELL_COST = TagKey.of(RegistryKeys.ITEM, Trickster.id("spell_cost")); public static final TagKey NO_SPELL_GLINT = TagKey.of(RegistryKeys.ITEM, Trickster.id("no_spell_glint")); + public static final TagKey WEAPON_SPELL_TRIGGERS = TagKey.of(RegistryKeys.ITEM, Trickster.id("weapon_spell_triggers")); public static final TagKey CONJURABLE_FLOWERS = TagKey.of(RegistryKeys.BLOCK, Trickster.id("conjurable_flowers")); public static final ItemGroup ITEM_GROUP = FabricItemGroup.builder() diff --git a/src/main/java/dev/enjarai/trickster/mixin/event/ServerPlayerEntityMixin.java b/src/main/java/dev/enjarai/trickster/mixin/event/ServerPlayerEntityMixin.java index 82456ca3..0c5c780e 100644 --- a/src/main/java/dev/enjarai/trickster/mixin/event/ServerPlayerEntityMixin.java +++ b/src/main/java/dev/enjarai/trickster/mixin/event/ServerPlayerEntityMixin.java @@ -27,6 +27,6 @@ public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile ) ) private void triggerItemSpell(Entity target, CallbackInfo ci) { - ItemTriggerHelper.triggerMainHand((ServerPlayerEntity)(Object)this, EntityFragment.from(target)); + ItemTriggerHelper.triggerMainHand((ServerPlayerEntity)(Object)this, true, EntityFragment.from(target)); } } diff --git a/src/main/java/dev/enjarai/trickster/spell/ItemTriggerHelper.java b/src/main/java/dev/enjarai/trickster/spell/ItemTriggerHelper.java index 8c86387b..4a7411bf 100644 --- a/src/main/java/dev/enjarai/trickster/spell/ItemTriggerHelper.java +++ b/src/main/java/dev/enjarai/trickster/spell/ItemTriggerHelper.java @@ -1,19 +1,22 @@ package dev.enjarai.trickster.spell; import dev.enjarai.trickster.cca.ModEntityCumponents; +import dev.enjarai.trickster.item.ModItems; import dev.enjarai.trickster.item.component.ModComponents; import net.minecraft.item.ItemStack; import net.minecraft.item.ToolItem; +import net.minecraft.registry.tag.ItemTags; import net.minecraft.server.network.ServerPlayerEntity; import java.util.List; import java.util.Optional; public class ItemTriggerHelper { - public static void triggerMainHand(ServerPlayerEntity player, Fragment... arguments) { + public static void triggerMainHand(ServerPlayerEntity player, boolean isWeaponTrigger, Fragment... arguments) { var stack = player.getMainHandStack(); + var item = stack.getItem(); - if (stack.getItem() instanceof ToolItem) { + if (item instanceof ToolItem || (isWeaponTrigger && stack.isIn(ModItems.WEAPON_SPELL_TRIGGERS))) { trigger(player, stack, List.of(arguments)); } } diff --git a/src/main/resources/assets/trickster/lavender/entries/tome_of_tomfoolery/trigger_items.md b/src/main/resources/assets/trickster/lavender/entries/tome_of_tomfoolery/trigger_items.md index 69208be3..7244f93a 100644 --- a/src/main/resources/assets/trickster/lavender/entries/tome_of_tomfoolery/trigger_items.md +++ b/src/main/resources/assets/trickster/lavender/entries/tome_of_tomfoolery/trigger_items.md @@ -6,12 +6,12 @@ ``` While the [Wand](^trickster:basics/wand) is the most common, and most versatile, way of quickly casting spells, it is not the only one available. -Described here are several alternative options that are worth considering. +Other items may cast their inscribed spell upon certain criteria being met. These items and their criteria are described here. ;;;;; <|page-title@lavender:book_components|title=Warrior's Rage|>On tools and melee weapons, -the Warrior's Rage executes the inscribed spell when bringing harm to an entity. The targeted entity received as the first argument. +the Warrior's Rage executes the inscribed spell when bringing harm to an entity. The targeted entity is received as the first argument. ;;;;; diff --git a/src/main/resources/data/trickster/tags/item/weapon_spell_triggers.json b/src/main/resources/data/trickster/tags/item/weapon_spell_triggers.json new file mode 100644 index 00000000..7a2c450b --- /dev/null +++ b/src/main/resources/data/trickster/tags/item/weapon_spell_triggers.json @@ -0,0 +1,5 @@ +{ + "values": [ + "minecraft:trident" + ] +} \ No newline at end of file