import './allanz/main';
import { world } from "@minecraft/server";
import './allanz/transfer-server';
import "./vendor_interact.js";
import "./plushie_place_entities.js";
import "./fishing_pack/main.js";

const DEBUG = true;

const ENTITY_COMMANDS = [
	{ id: "pr:pokemall_oak", command: "structure load mystructure:PokeMall_Oak ~ ~ ~" },
	{ id: "pr:acacia_village", command: "structure load mystructure:Acacia_village ~ ~-2 ~" },
	{ id: "pr:cherry_village", command: "structure load mystructure:cherry_village ~ ~-2 ~" },
	{ id: "pr:nether_village", command: "structure load mystructure:nether_village ~ ~-2 ~" },
	{ id: "pr:oak_village", command: "structure load mystructure:oak_village ~ ~-2 ~" },
	{ id: "pr:pokecenter_plans", command: "structure load mystructure:Pokecenter_plans ~ ~-2 ~" },
	{ id: "pr:pokemall_cave", command: "structure load mystructure:PokeMall_cave ~ ~ ~" }
];

world.afterEvents.entitySpawn.subscribe(event => {
	const entity = event.entity;
	if (!entity) return;
	if (entity.hasTag("structure_loaded")) return;

	const data = ENTITY_COMMANDS.find(e => e.id === entity.typeId);
	if (!data) return;

	const dimension = entity.dimension;
	const { x, y, z } = entity.location;

	dimension.runCommand(
		`execute positioned ${x} ${y} ${z} run ${data.command}`
	);

	entity.addTag("structure_loaded");
	entity.triggerEvent("minecraft:despawn");
});

import "./trainer_menu.js";
import "./fishing.js";