#How to detect if certain items are above a block?
10 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Hi! Could you be a little more specific about what you're trying to achieve?
helooo, i figured some things out
although im stuck trying to spawn the items in the world
...stuff that works before that
let aabb
try {
aabb = AABB.of(x, y, z, x + 1, y + 1, z + 1)
} catch (e) {
try {
const AxisAlignedBB = Java.type('net.minecraft.util.math.AxisAlignedBB')
aabb = new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1)
} catch (err) {
if (player) player.tell('Internal error, please report this message to the modpack author.')
return
}
}
let entities = []
try { entities = world.getEntitiesWithin(aabb) || [] } catch (e) {
try { entities = world.getEntitiesWithinAABB ? world.getEntitiesWithinAABB(aabb) : [] } catch (e2) { entities = [] }
}
let itemcount = 0
let items = []
entities.forEach(e => {
if (e.type !== 'minecraft:item') return
const item = e.item
if (!item) return
items[itemcount] = e
itemcount++
})
items.forEach(itemOne => {
items.forEach(itemTwo => {
if (itemOne.item.id === 'kubejs:wooden_handle' && itemTwo.item.id === 'kubejs:wooden_pickaxe_head' && itemOne !== itemTwo) {
itemOne.item.count -= 1
if (itemOne.item.count <= 0) itemOne.remove()
itemTwo.item.count -= 1
if (itemTwo.item.count <= 0) itemTwo.remove()
const newItem = new ItemEntity(world, x + 0.5, y + 0.5, z + 0.5, Item.of('minecraft:wooden_pickaxe', 1))
world.addEntity(newItem)
}
})
})
})
itemone and itemtwo exist although the items are not getting deleted
and the wooden pickaxe doesnt spawn
ok now for some reason its just the stick despawning, pickaxe isnt even spawning what
ok nooow its not letting me spawn the pickaxe breh