#Item entity rotation

31 messages · Page 1 of 1 (latest)

hollow dome
#

Hi,
I want to recreate the dragon hearth dropped effect of draconic evolution mod for a minecraft item ritual: I wrote this code but I don't know how to add rotation.
Thanks in advance.

BlockEvents.rightClicked('netherite_block', event => {
    const { level, block, server } = event

    let itemEntity = level.createEntity("item")
    itemEntity.y = block.pos.y + 1
    itemEntity.x = block.pos.x + 0.5
    itemEntity.z = block.pos.z + 0.5
    itemEntity.item = Item.of('netherite_ingot')
    itemEntity.item.count = 1
    itemEntity.noGravity = true
    itemEntity.motionY = 0.04
    // itemEntity.rotate($Rotation.NONE) // I don't see any difference...
    itemEntity.customName = 'Cosmos'
    itemEntity.customNameVisible = true
    server.tell(`Spawned! at ${itemEntity.x} ${itemEntity.y} ${itemEntity.z}`)
    itemEntity.spawn()
})
abstract pebbleBOT
#

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

finite sluice
#

wdym by rotate like have it spin on the ground?

hollow dome
#

Yes, but with rotation velocity increased.

humble osprey
#

i think you might need pitch and yaw

hollow dome
#

What are those?

finite sluice
#

fancy rotation words

humble osprey
#

Pitch, yaw and roll are the three dimensions of movement when an object moves through a medium.
The terms may be used to describe an aeroplane's movements through the air. They are also applied to watercraft moving through water, and spacecraft moving through space.
There are in fact six degrees of freedom of a rigid body moving in three-dimens...

finite sluice
#

have you seen any other packs do it?

humble osprey
#

I have a script I found that uses it

#

ill send it

hollow dome
hollow dome
humble osprey
#

@knotty anchor made this a while back

#

1 sec its too big XD

#
|function yawdelta(standard,target){
    let ntarget=target
    if(standard>ntarget){ntarget+=360}
    if(ntarget-standard>180){
        return ntarget-standard-360
    }
    else{
        return ntarget-standard
    }
}
console.log(Block.typeList)
ItemEvents.rightClicked("minecraft:netherite_ingot",event=>{
    let player=event.player
    player.swing()
    let yaw=player.yaw
    let storedyaw=player.persistentData.getInt("yaw")
    event.level.spawnParticles("minecraft:wax_off",false,player.x,player.y+1,player.z,0.3,0.5,0.3,50,0)
    if(storedyaw==0){
        player.persistentData.putInt("yaw",yaw);
    }
    else{
        let delta=yawdelta(storedyaw,yaw)
        if(delta>30){
            player.give("minecraft:gold_ingot")
        }
        else if(delta>-30){
            player.give("minecraft:emerald")
        }
        else{
            player.give("minecraft:diamond")
        }
    }
})
PlayerEvents.tick(event => {
let player = event.player;
    let storedyaw=player.persistentData.getInt("yaw")
    if(storedyaw==0){
        player.paint({
            diamond:{
                type: 'item',
                visible: false
            },
            emerald:{
                type: 'item',
                visible: false
            },
            gold_ingot:{
                type: 'item',
                visible: false
            }
        })
        return;
    }
#
    if(player.getMainHandItem()!='minecraft:netherite_ingot'){
        player.persistentData.putInt("yaw",0)
        return;
    }
    let delta=yawdelta(storedyaw,player.yaw)
    player.paint({
        diamond:{
            type: 'item',
            x:"$screenW/2-100",
            y:"$screenH/2+sin(time()*1.1)*$screenH/32",
            w:Math.max(Math.min(48,-delta),16)*2,
            h:Math.max(Math.min(48,-delta),16)*2,
            draw: 'ingame',
            item: 'minecraft:diamond',
            visible: true
        },
        emerald:{
            type: 'item',
            x:"$screenW/2",
            y:"$screenH/2+sin(time()*1.2)*$screenH/32",
            w:Math.max(48-Math.abs(delta),16)*2,
            h:Math.max(48-Math.abs(delta),16)*2,
            draw: 'ingame',
            item: 'minecraft:emerald',
            visible: true
        },
        gold_ingot:{
            type: 'item',
            x:"$screenW/2+100",
            y:"$screenH/2+sin(time()*1.3)*$screenH/32",
            w:Math.max(Math.min(48,delta),16)*2,
            h:Math.max(Math.min(48,delta),16)*2,
            draw: 'ingame',
            item: 'minecraft:gold_ingot',
            visible: true
       }
   })
})```
#

not quite sure how he did it, but that might give you somewhat of an idea of how it works. I dont 100% understand i

hollow dome
#

Ok, I'll try with this.

humble osprey
#

im not sure, but ItemEntity might have a pitch, yaw, roll paramater, you can check with probejs

hollow dome
humble osprey
#

ok

#

sounds good

hollow dome
#

I check player.yaw using PlayerEvents.tick and it's a value into range [-180, 180]. I tried change yaw to spawned item but I don't see effects.

#
BlockEvents.rightClicked('netherite_block', event => {
    const { level, block, server } = event

    let itemEntity = level.createEntity("item")
    itemEntity.y = block.pos.y + 1
    itemEntity.x = block.pos.x + 0.5
    itemEntity.z = block.pos.z + 0.5
    itemEntity.item = Item.of('netherite_ingot')
    itemEntity.item.count = 1
    itemEntity.noGravity = true
    itemEntity.motionY = 0.04
    itemEntity.customName = 'Cosmos'
    itemEntity.customNameVisible = true
    server.tell(`Spawned! at ${itemEntity.x} ${itemEntity.y} ${itemEntity.z}`)
    itemEntity.spawn()

    server.scheduleRepeatingInTicks(1, e => {
        let value = 0
        if (itemEntity.yaw == -180) {
            value = 1
        } else {
            value = -1
        }

        itemEntity.yaw = itemEntity.yaw + value
        server.tell(`Yaw ${itemEntity.yaw}`)
    })
})
humble osprey
#

i think it might be because your resetting the value at he beginning of your loop

#

you let value = 0 then you set it to 1 or -1, thats not much of a noticeable difference on a 360 degree axis

humble osprey
#

i gotta get some sleep soon, i can try to help when i wake up if you still need it

hollow dome
#

Ok, thanks.