Jan5676 Posted October 2, 2025 Report Posted October 2, 2025 Hi, I am currently developing a code mod, everything seems to be working fine so far, but I have come to the point, where I want to add a little animation to a block. I have created a Model in the VSModelCreator and imported it into the corresponding shapes directory in the mod path. This all works so far, I've now got a model with textures and all. Now I tried adding an animation to the block and it looked good in the Model Creator. I exported the file and now I have a JSON file with models AND an animation. This is the part that I think is probably important: "animations": [ { "name": "sprinklerTurn", "code": "sprinklerTurn", "quantityframes": 30, "onActivityStopped": "PlayTillEnd", "onAnimationEnd": "EaseOut", "keyframes": [...] } ] Now, I want to be able to play this animation on the Block (or rather the BlockEntity) that uses this model. I have already completed the rest of the mod and everything else is working with a Block and BlockEntity CS Class. This is my blocktype file: { "code": "tin_sprinkler", "class": "sprinklersmod.sprinkler", "entityClass": "sprinklersmod.blockEntitySprinkler", "blockmaterial": "wood", "creativeinventory": { "general": [ "*" ] }, "sidesolid": { "all": false }, "sideopaque": { "all": false }, "sounds": { "place": "game:block/planks", "break": "game:block/planks" }, "collisionbox": { "x1": 0.25, "y1": 0, "z1": 0.25, "x2": 0.75, "y2": 0.5, "z2": 0.75 }, "selectionbox": { "x1": 0.25, "y1": 0, "z1": 0.25, "x2": 0.75, "y2": 0.5, "z2": 0.75 }, "shapeByType": { "*": {"base": "block/tinsprinkler"} }, "textures": { "tinbronze": {"base": "game:block/metal/anvil/tinbronze"}, "brass": {"base": "game:block/metal/lantern/brass"} } } Theres still a bit of tweaking to be done here, but I registered the shape and now want to be able to access the animation. I was looking at many places for a way to do this, but I didn't really find much about the topic (only on how to create animations in the first place). So, my question is, how can I run the animation in my BlockEntity class the proper way? Which Class or Function do I need to call to make the block run its animation once? (In the best case asynchronously so it doesn't block the rest of the code from running). Bonus question: I want add a small "sprite" based water sprinkle animation to my block, but I didn't seem to find a way to make parts of a block model invisible unless called by the Keyframes to become visible. Is there a way for that?
Spear and Fang Posted October 5, 2025 Report Posted October 5, 2025 The rift ward is a good example of this that I've used for my own stuff https://github.com/search?q=repo%3Aanegostudios%2Fvssurvivalmod riftward&type=code
Diff Posted October 5, 2025 Report Posted October 5, 2025 I think I remember the Shiver's strokes being driven by code.
Jan5676 Posted October 10, 2025 Author Report Posted October 10, 2025 @Spear and Fang I see how it is supposed to work. However when trying to access BlockEntityAnimationUtil or BEBehaviorAnimatable my IDE tells me those could not be found, even though I am using the newest Vintage Story API as base for my project. Do I need to import or include it in some way?
Jan5676 Posted October 10, 2025 Author Report Posted October 10, 2025 Ah I found it, for some reason the VSEssentials.dll was not included in my Workspace by default. This snippet added to my csproj file fixed it:
Recommended Posts