#Animating an attachable

1 messages · Page 1 of 1 (latest)

silver plover
#

I have been trying to get an attachable to animate without adjusting any player files.

I have tried using the following script but get the error as shown:


world.afterEvents.itemUse.subscribe(({ itemStack, source }) => {
    source.playSound("item.book.page_turn");
    world.sendMessage("Test");
    source.playAnimation("animation.humanoid.attack.rotations");
});```

```[Scripting][error]-TypeError: not a function    at <anonymous> (main.js:7)```
#
    "format_version": "1.16.0",
    "minecraft:attachable": {
        "description": {
            "identifier": "piki_customcards:info_card",
            "materials": {
                "default": "entity_alphatest"
            },
            "textures": {
                "default": "textures/cards/card"
            },
            "geometry": {
                "default": "geometry.card_screen"
            },
            "animations": {
                "shuffle": "animation.piki_customcards.shuffle"
            },
            "scripts": {
                "animate": [
                    "shuffle"
                ] 
            },
            "render_controllers": [
                "controller.render.piki_customcards"
            ]
        }
    }
}
#

As you can see I am trying to trigger from the script.

edgy badge
#

You need to atleast use the Beta API 1.8.0-beta in the manifest.json to be able to run .playAnimation()

#

Alternatively, you can use .runCommandAsync() and /playanimation or smt if you want to keep it stable.

silver plover
#

I have tried this but with no luck 😦

sturdy galleon
#

From my understanding this isn’t possible. If you play an animation with /playanimation it will try to play an animation that the actual player model is able to do. But since you’re using an attachable, and none of the groups of the model exist in the player model, it isn’t going to work at all. I tried doing the same thing, and it didn’t work, it’s sad, but there are other methods…

#

Unless mojang was able to add something like “/playanimation item slot.weapon.mainhand minecraft:stick 1 animation.test” and “/playanimation entity @e[type=sheep] animation.test” which could solve the problem. So you could separate entity animations and attachable animations…

echo sphinx
#

They would have to add item.playAnimation

sturdy galleon
#

That would be useful

edgy badge
silver plover
sturdy galleon
#

I think you can possibly also detect the durability of the item itself, however, I'm unsure about that