/*
 * SPDX-FileCopyrightText: 2026 KOKA99CAB
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

package net.koka99cab.portals.portal;

import java.util.function.Predicate;

import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;

public record PortalDefinition(
		Identifier id,
		Block frameBlock,
		Item activationItem,
		Block portalBlock,
		ResourceKey<Level> destination,
		Predicate<BlockState> framePredicate
) {
	public PortalDefinition(Identifier id, Block frameBlock, Item activationItem, Block portalBlock, ResourceKey<Level> destination) {
		this(id, frameBlock, activationItem, portalBlock, destination, state -> state.is(frameBlock));
	}

	public boolean matchesFrame(BlockState state) {
		return framePredicate.test(state);
	}
}
