@@ -44,6 +44,7 @@ const itemTypes = {
44
44
"minecraft:netherrite_hoe"
45
45
]
46
46
} ;
47
+ import { InventoryComponentContainer } from "@minecraft/server" ;
47
48
import { world , Player } from "mojang-minecraft" ;
48
49
const enchants = { } ;
49
50
const names = { } ;
@@ -100,6 +101,10 @@ export function getEnchants(item) {
100
101
}
101
102
world . events . entityHit . subscribe ( ( { entity, hitBlock, hitEntity } ) => {
102
103
if ( entity instanceof Player ) {
104
+ /**
105
+ * @type {InventoryComponentContainer }
106
+ */
107
+ //@ts -ignore
103
108
const inv = entity . getComponent ( "inventory" ) . container ;
104
109
const item = inv . getItem ( entity . selectedSlot ) ;
105
110
if ( ! item )
@@ -114,6 +119,10 @@ world.events.entityHit.subscribe(({ entity, hitBlock, hitEntity }) => {
114
119
} ) ;
115
120
world . events . entityHurt . subscribe ( ( { hurtEntity, damagingEntity, damage } ) => {
116
121
if ( damagingEntity instanceof Player ) {
122
+ /**
123
+ * @type {InventoryComponentContainer }
124
+ */
125
+ //@ts -ignore
117
126
const inv = damagingEntity . getComponent ( "inventory" ) . container ;
118
127
const item = inv . getItem ( damagingEntity . selectedSlot ) ;
119
128
if ( ! item )
@@ -146,6 +155,11 @@ world.events.beforeItemUseOn.subscribe(({ source, item, blockLocation }) => {
146
155
}
147
156
} ) ;
148
157
world . events . blockBreak . subscribe ( ( { player, block, brokenBlockPermutation } ) => {
158
+
159
+ /**
160
+ * @type {InventoryComponentContainer }
161
+ */
162
+ //@ts -ignore
149
163
const inv = player . getComponent ( "inventory" ) . container ;
150
164
const item = inv . getItem ( player . selectedSlot ) ;
151
165
if ( ! item )
0 commit comments