import './components/blocks/lucky_block';
import './components/items/glass_sword';
import './components/items/lapis_sword';
import './components/items/creeper_sword';
import './components/items/spider_man_sword';
import './components/items/caidao';
import './components/items/virtue';
import './components/items/lock';
// debug
// world.beforeEvents.playerInteractWithBlock.subscribe((event) => {
//     if (!event.isFirstEvent) return;
//     const block = event.block;
//     const container = block.getComponent('inventory')?.container;
//     if (!container) return;
//     const lootManager = new LootContainerManager(world.getLootTableManager());
//     system.run(() => {
//         // 在数组里随机选择一个为战利品
//         const randomLoot = chestsLootlist[Math.floor(Math.random() * chestsLootlist.length)];
//         console.log(randomLoot);
//         lootManager.distributeLootToContainer(container, randomLoot);
//     });
// });
// 调试用：查看玩家使用的物品
// world.afterEvents.itemUse.subscribe((event) => {
//       const item = event.itemStack;
//     console.log(item.typeId);
//     const bundle = item.getComponent('inventory')
//     const container = bundle?.container;
//     if (C) {
//         console.log('has container');
//         container.setItem(0,new ItemStack('minecraft:diamond_sword'))
//     }
// })
// const bundle = 'minecraft:white_bundle'
// system.run(()=>{
//     const player = world.getAllPlayers()[0];
//     const mainhand = player.getComponent(EntityComponentTypes.Equippable)?.getEquipment(EquipmentSlot.Mainhand);
//     const playerContainer = player.getComponent('inventory')?.container;
//     const item = new ItemStack(bundle);
//     const itemContainer = item.getComponent('inventory')?.container;
//     if (itemContainer) {
//         itemContainer.setItem(0,new ItemStack('minecraft:diamond_sword'))
//     }
//     if (playerContainer) {
//         playerContainer.addItem(item);
//     }
// })
// 调试用：查看实体受到的伤害
// world.afterEvents.entityHurt.subscribe((event) => {
//     const entity = event.hurtEntity;
//     console.log("造成了",event.damage,"点伤害");
// })
// 调试用：查看实体生命值变化
// world.afterEvents.entityHealthChanged.subscribe((event) => {
//     const entity = event.entity;
//     console.log(entity.typeId, "的生命值改变为", event.oldValue,'=>',event.newValue);
// })
