Skip to content

Commit

Permalink
It must be done
Browse files Browse the repository at this point in the history
  • Loading branch information
StellarWitch7 committed Aug 25, 2024
1 parent 8cc3a94 commit 352ca5c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/dev/enjarai/trickster/Trickster.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/dev/enjarai/trickster/item/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -64,6 +61,7 @@ public class ModItems {
// public static final TagKey<Item> IMMUTABLE_SPELL_HOLDERS = TagKey.of(RegistryKeys.ITEM, Trickster.id("immutable_spell_holders"));
public static final TagKey<Item> SPELL_COST = TagKey.of(RegistryKeys.ITEM, Trickster.id("spell_cost"));
public static final TagKey<Item> NO_SPELL_GLINT = TagKey.of(RegistryKeys.ITEM, Trickster.id("no_spell_glint"));
public static final TagKey<Item> WEAPON_SPELL_TRIGGERS = TagKey.of(RegistryKeys.ITEM, Trickster.id("weapon_spell_triggers"));
public static final TagKey<Block> CONJURABLE_FLOWERS = TagKey.of(RegistryKeys.BLOCK, Trickster.id("conjurable_flowers"));

public static final ItemGroup ITEM_GROUP = FabricItemGroup.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
@@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

;;;;;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"minecraft:trident"
]
}

0 comments on commit 352ca5c

Please sign in to comment.