@@ -44,6 +44,7 @@ const itemTypes = {
4444 "minecraft:netherrite_hoe"
4545 ]
4646} ;
47+ import { InventoryComponentContainer } from "@minecraft/server" ;
4748import { world , Player } from "mojang-minecraft" ;
4849const enchants = { } ;
4950const names = { } ;
@@ -100,6 +101,10 @@ export function getEnchants(item) {
100101}
101102world . events . entityHit . subscribe ( ( { entity, hitBlock, hitEntity } ) => {
102103 if ( entity instanceof Player ) {
104+ /**
105+ * @type {InventoryComponentContainer }
106+ */
107+ //@ts -ignore
103108 const inv = entity . getComponent ( "inventory" ) . container ;
104109 const item = inv . getItem ( entity . selectedSlot ) ;
105110 if ( ! item )
@@ -114,6 +119,10 @@ world.events.entityHit.subscribe(({ entity, hitBlock, hitEntity }) => {
114119} ) ;
115120world . events . entityHurt . subscribe ( ( { hurtEntity, damagingEntity, damage } ) => {
116121 if ( damagingEntity instanceof Player ) {
122+ /**
123+ * @type {InventoryComponentContainer }
124+ */
125+ //@ts -ignore
117126 const inv = damagingEntity . getComponent ( "inventory" ) . container ;
118127 const item = inv . getItem ( damagingEntity . selectedSlot ) ;
119128 if ( ! item )
@@ -146,6 +155,11 @@ world.events.beforeItemUseOn.subscribe(({ source, item, blockLocation }) => {
146155 }
147156} ) ;
148157world . events . blockBreak . subscribe ( ( { player, block, brokenBlockPermutation } ) => {
158+
159+ /**
160+ * @type {InventoryComponentContainer }
161+ */
162+ //@ts -ignore
149163 const inv = player . getComponent ( "inventory" ) . container ;
150164 const item = inv . getItem ( player . selectedSlot ) ;
151165 if ( ! item )
0 commit comments