/*
 *  Copyright 2025-2026 R3944Realms
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package top.r3944realms.eroticdungeongame.api.event;

import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.event.IModBusEvent;
import org.jetbrains.annotations.Nullable;

/**
 * The type Un ride device event.
 */
public abstract class UnRideDeviceEvent extends Event implements IModBusEvent {
    private final Player target;
    private final BlockPos deviceBlockPos;
    private final BlockState deviceBlockState;
    private final BlockEntity seatBlockEntity;

    /**
     * Instantiates a new Un ride device event.
     *
     * @param target           the target
     * @param deviceBlockPos   the device block pos
     * @param deviceBlockState the device block state
     * @param seatBlockEntity  the seat block entity
     */
    protected UnRideDeviceEvent(Player target, BlockPos deviceBlockPos, BlockState deviceBlockState, BlockEntity seatBlockEntity) {
        this.target = target;
        this.deviceBlockPos = deviceBlockPos;
        this.deviceBlockState = deviceBlockState;
        this.seatBlockEntity = seatBlockEntity;
    }

    /**
     * Gets device block state.
     *
     * @return the device block state
     */
    public BlockState getDeviceBlockState() {
        return deviceBlockState;
    }

    /**
     * Gets target.
     *
     * @return the target
     */
    public Player getTarget() {
        return target;
    }

    /**
     * Gets device block pos.
     *
     * @return the device block pos
     */
    public BlockPos getDeviceBlockPos() {
        return deviceBlockPos;
    }

    /**
     * Gets seat block entity.
     *
     * @return the seat block entity
     */
    public BlockEntity getSeatBlockEntity() {
        return seatBlockEntity;
    }

    /**
     * The type Pre.
     */
    @Cancelable
    public static class Pre extends UnRideDeviceEvent {
        /**
         * The Seat entity.
         */
        @Nullable
        public final Entity seatEntity;


        /**
         * Instantiates a new Pre.
         *
         * @param target           the target
         * @param deviceBlockPos   the device block pos
         * @param deviceBlockState the device block state
         * @param seatBlockEntity  the seat block entity
         * @param seatEntity       the seat entity
         */
        public Pre(Player target, BlockPos deviceBlockPos, BlockState deviceBlockState, BlockEntity seatBlockEntity, @Nullable Entity seatEntity) {
            super(target, deviceBlockPos, deviceBlockState, seatBlockEntity);
            this.seatEntity = seatEntity;
        }

        /**
         * Gets seat entity.
         *
         * @return the seat entity
         */
        public @Nullable Entity getSeatEntity() {
            return seatEntity;
        }
    }

    /**
     * The type Post.
     */
    public static class Post extends UnRideDeviceEvent {
        /**
         * Instantiates a new Post.
         *
         * @param target           the target
         * @param deviceBlockPos   the device block pos
         * @param deviceBlockState the device block state
         * @param seatBlockEntity  the seat block entity
         */
        public Post(Player target, BlockPos deviceBlockPos, BlockState deviceBlockState, BlockEntity seatBlockEntity) {
            super(target, deviceBlockPos, deviceBlockState, seatBlockEntity);
        }
    }
}
