Surprise! We've been running on hardware provided by BuyVM for a few months and wanted to show them a little appreciation.
Running a paste site comes with unique challenges, ones that aren't always obvious and hard to control. As such, BuyVM offered us a home where we could worry less about the hosting side of things and focus on maintaining a clean and useful service! Go check them out and show them some love!
Description: Class that summons the projectile
Submitted on February 12, 2024 at 07:32 AM
Expires on February 11, 2025 at 07:32 AM (8 months from now)

package net.raguraccoon.ragu_testin.item.custom;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.raguraccoon.ragu_testin.entity.ModEntities;
import net.raguraccoon.ragu_testin.entity.custom.IncinerateBall;

public class MagicWand extends Item{
    public MagicWand(Properties properties) {
        super(properties);
    }
    public static String[] spells = {"Incinerate", "Stomp", "Encourage"};
    private String currentSpell;

    @Override
    public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand interactionHand) {
        if (!level.isClientSide && interactionHand == InteractionHand.MAIN_HAND) {
            ItemStack wand = player.getMainHandItem();

            if (!wand.hasTag()) {
                CompoundTag tag = new CompoundTag();
                tag.putInt("ragu_testin.spell_number", 0);
                wand.setTag(tag);
            }

            CompoundTag tag = wand.getTag();
            assert tag != null;
            currentSpell = spells[tag.getInt("ragu_testin.spell_number")];
            switch (currentSpell) {
                case "Incinerate":
                    incinerate(player, level);
                    break;
                case "Stomp":
                    player.sendSystemMessage(Component.literal("On Stomp"));
                    break;
                case "Encourage":
                    player.sendSystemMessage(Component.literal("On Encourage"));
                    break;
                default:
                    player.sendSystemMessage(Component.literal("Failure"));
                    break;
            }
        }
        return super.use(level, player, interactionHand);
    }

    private static void incinerate(Player player, Level level) {
        IncinerateBall incinerateBall = new IncinerateBall(ModEntities.INCINERATE_BALL.get(), player.getX(), player.getY() + 0.8, player.getZ(),  0, 0, 0, level);
        incinerateBall.shoot(player.getLookAngle().x(), player.getLookAngle().y(), player.getLookAngle().z(), 1f, 0);
        level.addFreshEntity(incinerateBall);
    }

    private static void stomp(Player player, Level level) {

    }

    private static void encourage(Player player, Level level) {

    }

}