#Set setItem as undefined
1 messages · Page 1 of 1 (latest)
what's the nullChecker?
that's what I use to check if a slot has nothing in it'
which would then lead to that slot being cleared with however it works
returns true when there is no item and returns false when there is an item
managed to get it to work
I switched to using commands and I ain't getting any errors throwing
try this
export function EnableCombatMode(player) {
const { dimension, headLocation, name } = player
const query = {location: headLocation, tags: [name], closest: 1};
const [invStore] = Array.from(dimension.getEntities(query));
if (!invStore) return;
const container = player.getComponent('inventory').container;
const inv = invStore.getComponent('inventory').container;
const voidItem = new ItemStack(MinecraftItemTypes.dirt,0);
for (let i = 0; i < 9; i++) {
if (!container.swapItems(i, i, inv)){
const myItem = container.getItem(i) ?? voidItem;
const invItem = inv.getItem(i) ?? voidItem;
container.setItem(i, invItem);
inv.setItem(i, myItem);
}
}
};
also, import ItemStack and MinecraftItemTypes
I've managed to get it working with my original code taking new ItemStack(MinecraftItemTypes.dirt,0);
ok
cool
thanks for the help man
w