package com.leisuretimedock.blasttravelreborn.api.events;

import com.leisuretimedock.blasttravelreborn.content.entity.CannonEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.IModBusEvent;

import javax.annotation.Nullable;

public abstract class CannonFireEvent extends Event implements IModBusEvent {
    private final CannonEntity cannonEntity;
    @Nullable
    private final Player firePlayer;
    @Nullable
    private final ItemStack fireStack;
    public CannonFireEvent(CannonEntity cannonEntity, @Nullable Player firePlayer, @Nullable ItemStack fireStack) {
        this.cannonEntity = cannonEntity;
        this.firePlayer = firePlayer;
        this.fireStack = fireStack;
    }

    public CannonEntity getCannonEntity() {
        return cannonEntity;
    }

    @Nullable
    public Player getFirePlayer() {
        return firePlayer;
    }

    @Nullable
    public ItemStack getFireStack() {
        return fireStack;
    }

    @Cancelable
    public static class Pre extends CannonFireEvent {

        public Pre(CannonEntity cannonEntity, Player firePlayer, ItemStack fireStack) {
            super(cannonEntity, firePlayer, fireStack);
        }
    }
    public static class Post extends CannonFireEvent {
        private final Vec3 firePos;
        private final Vec3 fireVel;
        public Post(CannonEntity cannonEntity, Player firePlayer, ItemStack fireStack, Vec3 firePos, Vec3 fireVel) {
            super(cannonEntity, firePlayer, fireStack);
            this.firePos = firePos;
            this.fireVel = fireVel;
        }
        public Vec3 getFirePos() {
            return firePos;
        }

        public Vec3 getFireVel() {
            return fireVel;
        }
    }
}
