#Bug with block place mob summon

16 messages · Page 1 of 1 (latest)

fossil rose
#

I'm trying to summon the Void Worm from Alex Mobs in a similar way to an iron golem. While the script works, the worm summons at only half the size. I'm assuming this is a weird bug having to do with the multi-parted entity, but would there be a way to workaround this issue?

BlockEvents.placed('alexsmobs:void_worm_effigy', e => {
    if (e.block.down != 'minecraft:iron_block' || e.block.down.down != 'minecraft:iron_block') return
    e.block.set('air')
    e.block.down.set('air')
    e.block.down.down.set('air')
    const { x, y, z } = e.block.pos;
    e.server.runCommandSilent(`playsound alexsmobs:void_worm_idle player @p ${x} ${y} ${z}`);
    const worm = e.block.createEntity("alexsmobs:void_worm")
    worm.setPosition(x + 0.5, y + 15, z + 0.5);
    worm.spawn();
})
dusky yewBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

fossil rose
#

Anyone have a fix for this?

pearl ingot
#

I am not very sure about this. but If you can find the last part of the worm, maybe you can summon new parts with correct ParentUUID to elongate the worm.

pearl ingot
#
const getAABBofRadius = (centerX, centerY, centerZ, radius) => {
    const [minX, minY, minZ, maxX, maxY, maxZ] = [-1, 1].map(c => [centerX, centerY, centerZ].map(n => n + radius * c)).reduce((a, b) => a.concat(b))
    const aabb = AABB.of(minX, minY, minZ, maxX, maxY, maxZ)
    return aabb
}

const wormHeadEntityType = "alexsmobs:void_worm"
const wormPartEntityType = "alexsmobs:void_worm_part"
const wormsUUIDmap = {}
/**
 * 
 * @param {Internal.Level_} level 
 * @param {*} tickCount 
 * @param {Internal.AABB_} aabb 
 */
const getWormTail = (level, tickCount, aabb) => {
    let uuidHashcode
    wormsUUIDmap[tickCount].forEach(n => uuidHashcode = n)
    return level.getEntitiesWithin(aabb).filter(entity => entity.nbt.UUID.hashCode() == uuidHashcode)[0]
}

EntityEvents.spawned([wormHeadEntityType, wormPartEntityType], event=>{
    const {entity:{nbt, nbt:{UUID:wormUUID}, type, x, y, z}, server, server:{tickCount:rawTickCount}, level} = event
    let tickCount = rawTickCount
    if(type == wormHeadEntityType) tickCount += 1
    wormsUUIDmap[tickCount] = wormsUUIDmap[tickCount] || new Set()
    wormsUUIDmap[tickCount].add(wormUUID.hashCode())
    const ParentUUID = nbt.ParentUUID
    if(!ParentUUID) return
    function deleteHavingParent (ParentUUID){
        server.scheduleInTicks(1, _ => {
            wormsUUIDmap[tickCount].delete(ParentUUID.hashCode())
        })
    }
    deleteHavingParent(ParentUUID)
})


BlockEvents.placed(event=>{
    let {block, server, server:{tickCount}, level} = event
    let worm = block.createEntity("alexsmobs:void_worm")
    let {x, y, z} = worm
    worm.spawn()
    server.scheduleInTicks(3, _=>{
        let wormTail = getWormTail(level, tickCount + 1, getAABBofRadius(x, y, z, 50))
        console.log(wormTail.nbt)
        let newWormPart
        for(let i = 0; i < 10; i++){
            newWormPart = level.createEntity(wormPartEntityType)
            newWormPart.setPosition(x, y + 10, z)
            newWormPart.mergeNbt({ParentUUID: wormTail.nbt.UUID, BodyIndex: wormTail.nbt.BodyIndex + 1, TailPart: true})
            newWormPart.spawn()
            console.log(newWormPart.nbt)
            wormTail = newWormPart
        }
    })
})
#

The concept might be doable. This adds new body parts to the worm summoned by block placed event. However, the body parts added by this method do not attach to the main part in a proper way. I don't know which nbt to modify their behavior there.

fossil rose
# pearl ingot

Hm, alright. I’ll have to see what could possible be done then.

#

Would there be a way to trigger a /summon command instead? I know that way summons the proper full worm.

pearl ingot
pearl ingot
#

btw, may you share the summon command here as well? I am also curious about that.

fossil rose
pearl ingot
fossil rose
#

I knew the command existed but wasn’t sure how to get it to fire with a block summon.

pearl ingot
#

iirc, this one is also slightly shorter than the natural generated one. But it's definitely better anyway.

fossil rose
#

Oh I’ve never noticed it’s smaller than the natural one, so it’s definitely big enough. XD