#EntitiyJS Anim Command

615 messages · Page 1 of 1 (latest)

reef briar
#

Is there any way to make entities animations play via commands?

"/entityjs anim state entitiyid animationname"
"/entityjs anim stop entityid"

royal cragBOT
#

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

reef briar
#

since its a new plugin can't really make a script for it

#

@dawn oar

dawn oar
#

in what instance would you use a command to change the animation?

#

when the animal attacks or something?

#

or when certain conditions are met?

reef briar
#

well it's a bit specific and probably not supported but

#

let me say the cursed word

#

I am working on a hybrid server atm

#

so to interface with plugins I need to create a command for it

dawn oar
reef briar
#

yeah..

dawn oar
#

why not just specify what the entity is doing like this?

StartupEvents.registry('entity_type', event => {
    event.create('wyrm', 'entityjs:animal')
        .addAnimationController('exampleController', 20, event => {
            // Define conditions for the animation to be played based on the entity.
            if (event.entity.hurtTime > 0) {
                event.thenPlayAndHold('spawn');
            } else {
                event.thenLoop('idle'); 
            }
            return true; // Some boolean condition indicating if the animation should be played;
        });
})```
#

since you have the entity here you can do whatever

reef briar
#

or we can use pData for it right?

dawn oar
#

yes

#

if you have the entity you have pdata

reef briar
#

and register command for giving entities pdata

dawn oar
#

yup

reef briar
#
StartupEvents.registry('entity_type', event => {
    event.create('wyrm', 'entityjs:animal')
        .addAnimationController('exampleController', 20, event => {
            // Define conditions for the animation to be played based on the entity.
            if (event.entity.persistentData.animstate == "attack1") {
                event.thenPlayAndHold('attack1');
            } else {
                event.thenLoop('idle'); 
            }
            return true; // Some boolean condition indicating if the animation should be played;
        });
})```
#

so this should work

dawn oar
#

if that works in a regular event to return true in the if statement then it will work here yes

reef briar
#

wait so animation controller checks the events every tick?

dawn oar
#

yup

reef briar
#

oh

#

lets

sharp heronBOT
reef briar
#

kubejs + entityjs wouldn't be a problem I think

#

so you finished the wiki or do I need to use probejs

dawn oar
#

wiki should be well documented

#

i even added full example usages with every possible method overridden

reef briar
#

hmm what are the paths for models

#

.geo
.anim
and textures

dawn oar
#

should be whatever geckolib 4 set it up as

#

sec

#

"kubejs:animations/entity/wyrm.animation.json"
"kubejs:geo/entity/wyrm.geo.json"
"kubejs:textures/entity/wyrm.png"
for example if you didnt put a namespace in the .create("wyrm") itd look for it in the kubejs folder

reef briar
#

oh wait I am using "reina" namespace

dawn oar
#

so itd be reina instead of kubejs in the folder path

#

although it should default to it without the need to manually set it in the startup script

#

.create("reina:wyrm") if you do that that is

reef briar
#

oh oh

#

thanks

dawn oar
#

ye

reef briar
#

trying right now

#

can I check for if animation is valid?

#

IT WORKS

dawn oar
#

in what instance would the animation be invalid?

#

and nice heh

reef briar
dawn oar
#

hmmm probably not without me directly checking for it in the geckolib mod since they handle that part

reef briar
#

yeah no problem

#

IT WORKS

#

EVEN THE ANIMATON PLAYED

#

CAN YOU BELIEVE THAT??

dawn oar
#

id hope so

#

would be bad if it didnt heh

reef briar
#

I forget to remove the hitbox cube in blockbench so it looks a bit messy but currently fixing it

dawn oar
reef briar
dawn oar
#

20 is the transition time between animations

#

20 ticks

#

prob wanna set it to something like 5

reef briar
#

fair enough

#

game is booting let me share some screenshots

dawn oar
#

you can return with the js if (event.entity.age % 20 != 0) return trick if needed tho youll have to be careful you arent having any animation downtime or else it'll look weird

reef briar
#

let me post it on offtopic so everyone sees it

dawn oar
#

sure

reef briar
#

if I want to play it once and continue to idle animation

#

oh wait I forget about wiki

dawn oar
#

theres a way to tell the animation time, lemme check

#

if you have probejs it should tell you with the event. too

reef briar
#

well I'm at my home pc (that I never use) so I don't have probejs

dawn oar
#

event.animationTick

#

gets the animation tick the animations been playing for

#

np

reef briar
#

oh wait

dawn oar
#

youll have to know how many ticks your animation is though

reef briar
#

I want to make the animation play once

dawn oar
#

if (event.animationTick > 120) do stuff

#

oh

#

thenPlayAndHold

#

is the play once

reef briar
#

oh really?

dawn oar
#

it plays then holds on the last frame

reef briar
#

I thought hold indicates to stop all the animations

#

so when stopped it will continue to idle since else is set to idle right?

dawn oar
#

itll play once til you set another animation to play

#

so for example if you got rid of all those if statements

reef briar
#

so I will set to the walking if entity is moving?

dawn oar
#

yes

reef briar
#

thanks a lot

dawn oar
#

if js (event.isMoving())

reef briar
#

let me test the other things and close this ticket

dawn oar
#

you have the direct boolean to if the entity is moving

reef briar
#

and use thenPlayAndHold again?

dawn oar
#

no youd loop prob

reef briar
#

okay

dawn oar
#

as long as the entity is moving you'd loop

#

id imagine thatd be the smoothest way to go about it anyways

reef briar
#

and how can I register a command? in serverside

#

never tried

dawn oar
#

theres already a persistentdata/scoreboard command with kubejs

reef briar
#

but I can't set anything with it I think

dawn oar
#

sec

sharp heronBOT
#

[➤](#1198605420395233380 message) In the picture is what I get when I do /kubejs persistent_data server get itemDetails. I wanted to reset the item details, so I did /kubejs persistent_data server merge {itemDetails:{}}, but it changed nothing. Setting it to a number or a string works.

dawn oar
#

something like what dragons doing

reef briar
#

yeah woekd

dawn oar
#

except itd be like /kubejs persistent_data server merge {animation:{1}} or something

reef briar
#

worked

dawn oar
#

nice

reef briar
#

but needs to restart

#

1min

#

I need to download optimisation mods asap.

#

oh it crashed

#

yeah summoning the mob crashes it

sharp heronBOT
#

Paste version of message.txt from @reef briar

reef briar
#
StartupEvents.registry('entity_type', event => {
    event.create('reina:mfwardenarcher', 'entityjs:animal')
        .addAnimationController('exampleController', 5, event => {
            // Define conditions for the animation to be played based on the entity.
            if (event.entity.persistentData.animState) {
              event.thenPlayAndHold(event.entity.persistentData.animState);
            } 
            if (event.entity.isMoving()) {
              event.thenLoop("walk");
            }
            else {
                event.thenLoop('idle'); 
            }
            return true; // Some boolean condition indicating if the animation should be played;
        });
})```
startup script
#

this is the line 236

#

removed the ismoving part

#

and now the animations with "event.entity.persistentData.animState" does not play

dawn oar
#

its event.isMoving() not event.entity.isMoving()

reef briar
#

gotcha

#

what about the animation part

dawn oar
#

what animation

reef briar
#

sorry its 5 am in here waited for this all day.

dawn oar
#

uh

#

imma help you out with something sec

reef briar
#

yeah no problem

#

"kick" is a valid animation btw

dawn oar
#

do this ```js
StartupEvents.registry('entity_type', event => {
event.create('reina:mfwardenarcher', 'entityjs:animal')
.addAnimationController('exampleController', 5, event => global.animations(event));
})
/**
*

  • @param {Internal.BaseLivingEntityBuilder$AnimationEventJS<any>} event
    */
    global.animations = event => {
    // Define conditions for the animation to be played based on the entity.
    if (event.entity.persistentData.animState) {
    event.thenPlayAndHold(event.entity.persistentData.animState);
    }
    if (event.entity.isMoving()) {
    event.thenLoop("walk");
    }
    else {
    event.thenLoop('idle');
    }
    return true; // Some boolean condition indicating if the animation should be played;
    }``` so you can live edit it with /kubejs reload startup_scripts
#

global events will be your best friend using entityjs

reef briar
#

yes it is working other then event.entity.persistentData.animState part

#

reloading is now fine

dawn oar
#

im gonna have to take a look at this tomorrow when i have an instance open

reef briar
#

😭

#

no problem!!

dawn oar
#

im going to be implimenting on event-like animation triggers for stuff like this but i havent gotten around to it yet

reef briar
#

oh so the problem is not about the code?

dawn oar
#

thats what geckolib has and i will be able to impliment it easily i assume

#

the issue is the code yes

#

the way youre detecting that persistent data is wrong

#

but yeah theres better ways to impliment stuff like this on my end too

reef briar
dawn oar
#

i'll look into stuff like this tomorrow i guess

sharp heronBOT
#

[➤](#1211848958889172992 message) im gonna have to take a look at this tomorrow when i have an instance open

dawn oar
reef briar
#

okay than no need to bother you

dawn oar
#

its all g

#

ill let you know tomorrow when ive taken a deeper look at it

reef briar
#

okay okay!!

reef briar
#

@dawn oar sorry for ping but how did it go?

dawn oar
#

have yet to try it

reef briar
#

k k!

dawn oar
#

oh

#

you probably need to initialize the persistent data first

#

on the entity

#

cant merge with no value, you have to set it to something first

reef briar
dawn oar
#

whats the command you have

reef briar
#

I'm just confused

dawn oar
#

send it here

dawn oar
#

in the if statement

reef briar
#

well currently there is no command

dawn oar
#

you have to initiate it first before you can read from the if

reef briar
#

I just made with merge

reef briar
dawn oar
#

sec

sharp heronBOT
#

[➤](#1165567460242640896 message) you would just give them the pdata elytratimer 1(this is needed to initiate the pdata on the player) with the command

reef briar
#

so I will create a new event everytime a mob spawns and give it that pdata right?

dawn oar
#

UH

#

first id like to see how you'd impliment it "attacking" something

#

cause you'll need goals for that

#

for example this ```js
//addGoalSelectors Server Script
EntityJSEvents.addGoalSelectors('kubejs:wyrm', e => {
let Player = Java.loadClass('net.minecraft.world.entity.player.Player')
//You have the ability to add pre built goals like so to your entity. (with more to come!)
e.panic(1, 0.5)
e.floatSwim(1)
e.meleeAttack(4, 1, true)
e.leapAtTarget(3, 0.4)
e.waterAvoidingRandomStroll(5, 0.4, 0.8)
e.lookAtEntity(6, Player, 8, 0.8, false)
e.randomLookAround(7)
})

//addGoals Server Script
EntityJSEvents.addGoals("kubejs:wyrm", event => {
let Cow = Java.loadClass('net.minecraft.world.entity.animal.Cow')
event.hurtByTarget(1, [Cow], true, [Cow])
event.nearestAttackableTarget(2, Cow, 5, false, false, entity => {
return entity.age < 500
})
})``` would make your mob attack a cow on sight

#

though youll have to change out "kubejs:wyrm" to your mob

reef briar
#

I currently didn't implement attacking

dawn oar
#

i wonder if theres an "isattacking" method somewhere we could use here hmmm

reef briar
#

so wait

#

I'm confused

#

I just want to make entity play animation not implement attacking etc.

dawn oar
#

ok back to my earlier question then, how will your entity attack?

reef briar
#

well, in past I was using item displays connected to eachother to create one model, each item display had models 1 bone and together they created the model, but it was so laggy and all serverside

#

but for animations I implemented custom functions to my code so

#

I just need to replace that buggy ass animation code with command that entity runs it

#

attacking, custom attacks, death animations etc. everything is handled in serverside not in kubejs

#

so I just need to create a command to make an entity play animation, and integrate that command with my code

#

yeah brain burning I know

#

but currently it is the fastest method

#

that way I will only change this to

#

with this

#

or something similar

#

I hope you get the main idea

dawn oar
#

cause i know geckolib adds this functionality built into their mod already

reef briar
#

oh so wontfix?

dawn oar
#

btw intead of commands you could easily replicate it by setting the persistent data directly through the onevent methods the entity already has

#

theres an .onDeath method you have already

reef briar
#

there are custom animations that I don't want to implement through kubejs

dawn oar
#
.onDeath(context => {
            const { damageSource,entity } = context
            entity.persistentData
        })```
reef briar
#

so wontfix or scheduled?

dawn oar
#

yeah im gonna look into it on the dev side, might be a while before i figure it out tho

reef briar
#

no problem take your time

#

creating a custom .onPData event pepepoggers

dawn oar
#

theres also .doAutoAttackOnTouch

reef briar
#

well should I just close this now?

dawn oar
#

keep it open til i get back with you about it

#

also gonna put this here incase you need it for an attack js .doAutoAttackOnTouch(context => { const { target, entity } = context })

reef briar
#

yeah I was thinking about that

#

implementing common animations like walk, attack, death on kubejs and leave rest (bossattack1, kick, digdown, etc.) animations to my code but I dunno

#

oh and another question

dawn oar
#

sup

reef briar
#

what about tracking the head to look at player?

#

I think gecko just make you chose the head bone and handle the rest (lookin around, looking at player)

dawn oar
#

you should have raytracing i believe on the entity

#

sec

#

entity.rayTrace()

reef briar
#

thanks!!

dawn oar
reef briar
#

lmk when you find a solution or implement the onPersistentData event or I dunno

dawn oar
#

will do!

reef briar
#

I hope that won't be that hard to implement

#

I waited about this since 1.16 I think despair

dawn oar
#

lmao

dawn oar
#

ok so update on the event stuff

#

theres an entity.swinging method you may also be able to work with and is what geckolib also does for a duel wielding attack animation

#

might be worth considering

reef briar
#

thanks!

dawn oar
#

that way you can call them to swing whenever with entity.swing()

#

np!

reef briar
#

I hope my request will be implementable

dawn oar
#

if its onpdata then no

#

cause thats not a thing that can be tracked

reef briar
#

no not that

dawn oar
#

oh

#

yeah im still looking into the event stuff forsure

reef briar
#

okay thanks!

dawn oar
#

aight this will be in the next update js StartupEvents.registry('entity_type', event => { event.create('wyrm', 'entityjs:animal') .onLivingJump(entity => { entity.triggerAnimation('examplecontroller', 'triggername') }) .addTriggerableAnimationController('examplecontroller', 5, 'triggername', 'spawn', 'loop') })

#

well, something like it

reef briar
#

wait so

#

still confused

dawn oar
#

this way you can play any animation right off the entity js entity.triggerAnimation('examplecontroller', 'triggername')

#

np

#

whenever you want smugava

reef briar
#

don't bother explaning probably forget anyways

dawn oar
#

should

reef briar
#

I will wait for release

reef briar
#

I am really confused

reef briar
#

this is not the version that adds "addTriggerableAnimationController" I assume

dawn oar
#

i havent posted the update yet

#

still figuring out some things like making it compatible with other animation controllers ect

#

ill let you know when its posted, might be tomorrow i assume if all goes well

reef briar
#

okay!!

dawn oar
#

just uploaded the new versions, they should be up soon

dawn oar
# reef briar okay!!

and since it's a literal trigger you can call anywhere it should be a lot better than setting it with persistent data, for example you would add the triggerable animation controller on startup like so js StartupEvents.registry('entity_type', event => { event.create('wyrm', 'entityjs:animal') .addTriggerableAnimationController('exampleController', 5, 'spawn', 'spawning', 'play_once') });

which you can then call anywhere you need like this js EntityEvents.hurt('kubejs:wyrm',event => { event.entity.triggerAnimation('exampleController', 'spawning'); }) this includes for example the forge livingattack event

reef briar
#

oh god thanks!

#

will try now

#

well @dawn oar is there a way to parse entity by it's id?

dawn oar
#

you mean like "mymodid:myentityname"?

#

should be entity.type

reef briar
#

nah lets say I registered a command

dawn oar
#

ah

#

uuid?

reef briar
#

yes yes

#

that one

dawn oar
#

event.entity.uuid i think

reef briar
#

sorry wrong question

#

get entitiy by its uuid

dawn oar
sharp heronBOT
#

[➤](#off-topic message) ServerLevel.getEntity(UUID)

reef briar
#

thanks!!

reef briar
#

how does it work actually

dawn oar
#

so lets take this for example js .addTriggerableAnimationController('exampleController', 5, 'spawn', 'spawning', 'play_once')
its pretty much the same as adding a normal controller except instead of setting the callback predicate function you will need to specify the animation name (in this case the animation name in my animations.json is 'spawn') the trigger identifier(a unique name to identify the trigger which you will be able to use anywhere) and the loop type(im using 'play_once' here but you have 'loop', 'default', 'play_and_hold' as well)

dawn oar
reef briar
#

oh so basicly;

.addTriggerableAnimationController('controllername', animationtick(?), 'modelsanimationname', 'entityjsanimationname', 'animationtype')```
dawn oar
#

no spaces ahujel

#

but ye

#

animation loop type

reef briar
#

I can work with that

dawn oar
#

if you want it to default to the loop type specified in the json you'd just put "default"

dawn oar
#

np

reef briar
# dawn oar np

can I register more than 1 animations to a controller?

#

Damn I should read the wiki I guess

#

lemme look

dawn oar
#

however you can do this if you only want to use the triggerable animations within the entity's methods like so ```js
.addAnimationController('exampleController1', 5, event => {
// Add triggerable animation named "spawning" with loop type "default"
event.addTriggerableAnimation('spawn', 'spawning', 'default');

        // Play "idle" animation if the entity is moving
        if (event.isMoving()) {
            event.thenPlay("idle");
        }
        return true; // Indicate successful animation setup
    })```
reef briar
#

I mean I want to manage all my triggerable animations under 1 controllers name

dawn oar
#

here you can add multiple to one controller through this under the same controller name js event.addTriggerableAnimation('spawn', 'spawning', 'default'); though you probably just want to make a new controller for every animation because thats how normal geckolib does it anyways

#

this is using the js .addAnimationController method though

reef briar
sharp heronBOT
reef briar
#
ServerEvents.commandRegistry(e => {
    const { commands: Commands, arguments: Arguments } = e
    let entity = ServerLevel.getEntity(UUID)

    e.register(Commands.literal('anim')
      .requires(s => s.hasPermission(2))
      .then(Commands.argument('target', Arguments.ENTITY.create(e))
        .executes(c => anim(Arguments.ENTITY.getResult(c, 'target')))
      )
    )
    let anim = (entity) => {
        entity.triggerAnimation('kickController', 'kick');
    }
})
dawn oar
#

well ofcourse thatd be undefined

#

you have to get the server level through the entity

#

entity.level

#

its not just ServerLevel heh

reef briar
#

fair enough

dawn oar
#

its the level resourcekey not dimension mb

#
PlayerEvents.tick(event => {
    event.entity.server.getLevel(event.entity.level.dimensionKey)
})```
reef briar
#
ServerEvents.commandRegistry(e => {
    const { commands: Commands, arguments: Arguments } = e

    e.register(Commands.literal('anim')
      .requires(s => s.hasPermission(2))
      .then(Commands.argument('target', Arguments.STRING.create(e))
        .executes(c => anim(Arguments.STRING.getResult(c, 'target')))
      )
    )
    let anim = (entity) => {
        let entity2 = e.server.level.getLevel().getEntity(entity)
        entity2.triggerAnimation('kickController', 'kick');
    }
})```

well it seems it is not working and no error logs
#

model is registered and shows but

dawn oar
#

again, why does this have to be a command

reef briar
#

well as I explained because of creating compability with my other tools

dawn oar
#

hmm

#

the plugin?

reef briar
#

yeah the plugin

dawn oar
#

what does this plugin do?

reef briar
#

I know it is not supported so I'm asking as a command

dawn oar
#

btw whats your startup script look like

reef briar
#

think like that

reef briar
# dawn oar btw whats your startup script look like

well it's a long ass file but here is the only model part;

StartupEvents.registry('entity_type', event => {
    event.create('reina:mfwardenarcher', 'entityjs:animal')
    .addTriggerableAnimationController('kickController', 5, 'kick', 'kick', 'play_once')
    .addAnimationController('exampleController', 5, event => {
        event.thenLoop('idle'); 
        return true;
    });
})```
#

well I got everything wrong didn't I

dawn oar
#

im honestly not the guy to go to for commands

#

what i would do is make it do something simple and make sure it's working properly

#

like have it kill the entity for example

#

also the entity is an instance so if you dont have the actual entity instance then it prob wouldnt work anyways

#

and what i mean by this is for example js EntityEvents.hurt(event => { event.entity }) has the instance of the entity being hurt here

reef briar
dawn oar
#

and i know youre getting the entity through uuid but make sure thats the right entity

dawn oar
#

yes so console log that and make sure its the right one

reef briar
#

letme test

dawn oar
#

kk

reef briar
#

thanks for advice

#

oh wait there is a command problem it seems

#
let entity2 = e.server.level.getLevel().getEntity(entity)```
#

this part is wrong

#

there is no e.server.level

#

oh yeah

#

since I need to get entities server level

#

well yeah

#
function getEntityByID(uuid) {
    let entities = Utils.server.getEntities();
    for (let i = 0; i < entities.size(); i++) {
        console.log(entities.get(i).uuid);
        if (entities.get(i).uuid == uuid) {
            return entities.get(i)
        }
    }
}

ServerEvents.commandRegistry(e => {
    const { commands: Commands, arguments: Arguments } = e

    e.register(Commands.literal('anim')
      .requires(s => s.hasPermission(2))
      .then(Commands.argument('target', Arguments.STRING.create(e))
        .executes(c => anim(Arguments.STRING.getResult(c, 'target')))
      )
    )
    let anim = (entity) => {
        let entity2 = getEntityByID(entity)
        entity2.triggerAnimation('kickController', 'kick');
    }
})

I'm left with this now

dawn oar
#

why you doing server.level.getlevel?

reef briar
#

Cannot call method "triggerAnimation" of undefined

reef briar
reef briar
dawn oar
#

the entity is undefined

reef briar
#

f

#

my command is totally messed up I guess

dawn oar
#

in what instance would you use the command

#

in game?

#

you would run the command in game to make an entity animate but how would you know their uuid in the first place

#

earlier you were talking about using persistent data to trigger it

#

all through a command

reef briar
#

well now

dawn oar
#

and now i want to know how would you execute the command in the first place thonk

reef briar
#
ServerEvents.commandRegistry(e => {
    const { commands: Commands, arguments: Arguments } = e

    e.register(Commands.literal('anim')
      .requires(s => s.hasPermission(2))
      .then(Commands.argument('target', Arguments.ENTITY.create(e))
        .executes(c => anim(Arguments.ENTITY.getResult(c, 'target')))
      )
    )
    let anim = (entity) => {
        entity.triggerAnimation('kickController', 'kick');
    }
})```

I can get entity through args
dawn oar
#

is there some place in configs where you need a command to do something?

reef briar
#

yeah

dawn oar
#

also you should link the plugin here so i can take a look

reef briar
#

well it's custom made from my team

dawn oar
#

and what does it do exactly

reef briar
#

well you see we are using this plugin to manage mobs AI, skills etc.

dawn oar
#

through commands?

#

oh god
\

reef briar
#

will explain a bit later wait

dawn oar
#

maybe the persistent data way is better then

#

with the command

reef briar
#

maybe

dawn oar
#

though you'll have to listen to the pdata somehow

#

you're trying to do all this through the server and no startup scripts?

#

are startup scripts allowed or nah

reef briar
#

allowed

dawn oar
#

aight

#

i have an idea

reef briar
#

well I want to make it modular so

#

yeah tell me

dawn oar
#

forge right

reef briar
#

yes

dawn oar
#
.tick(entity => global.entitytick(entity)

/**
 * 
 * @param {Internal.LivingEntity} event 
 */
global.entitytick = entity => {
    if (entity.persistentData.kick == 1){
        entity.persistentData.kick = 0
        entity.triggerAnimation('kickController', 'kick');
    }
}```
#

this way it'll literally act as a trigger detecting on the entity tick if it's persistent data is 1 or not

#

although crap we can just do this off the entity tick despair

#

sec

reef briar
#

yeah..

#

but running it every tick woudn't make server lag..

dawn oar
#

there

#

it shouldnt as long as you're only reading pdata

reef briar
#

oh okay then I can work with that

dawn oar
#

although setting it up on the actual entity itself on lets say the doautoattackontouch method would do the same thing though you said earlier you werent trying to do ai at all?

reef briar
#

well you're entirely right I can manage this all by only kubejs itself but

dawn oar
#

this for example this would add the attack goal to the mob and they would attack cows on sight #off-topic message

sharp heronBOT
#

[➤](#off-topic message)

EntityJSEvents.addGoalSelectors('kubejs:wyrm', e => {
    e.meleeAttack(4, 1, true)
})
EntityJSEvents.addGoals("kubejs:wyrm", event => {
    let Cow = Java.loadClass('net.minecraft.world.entity.animal.Cow')
    event.hurtByTarget(1, [Cow], true, [Cow])
    event.nearestAttackableTarget(2, Cow, 5, false, false, entity => {
        return entity.age < 500
    })
})``` in server scripts
reef briar
#

but however my dev team decided to make a hybrid server

dawn oar
#

i would tell them that this is better done in the startup upon entity creation

#

it'd definately be more performant than having command overhead too

reef briar
#

they woudln't listen..

dawn oar
#

they dont know the power of kubejs i assume

#

and if they're trying to do everything through commands then thats even worse if you ask me

#

no offense of course

#

i would show them that ai is entirely possible through this mod

#

up to you tho

reef briar
#

well you're right since I'm kinda head of dev

#

don't know if I can make them listen

#

they have something working right now and only need is make entity animation through, pdata or commands

dawn oar
#

ok, try the pdata script i sent you and see if it works

#

you still have the pdata command right

#

should just have to set the pdata to 1 then it'll trigger and set it back to 0

#

although you'll have to set the pdata to 0 upon entityevents.spawned to initiate it first ofcourse

reef briar
#

will try thanks

dawn oar
#

also it was dumb i asked if startup scripts were allowed earlier 💀

#

entityjs is startup script despair

reef briar
#

maybe that's why it did not work in the serverside.

#

makes sense now

reef briar
#

this goes to startupevents?

#

yeah it was a stupid question

dawn oar
#

its the entity tick method

dawn oar
#

but yeah you'd override the tick method in your entity

reef briar
dawn oar
#

yes

#

/kubejs reload startup_scripts

reef briar
#

[23:01:40] [ERROR] ! reina_startup.js#238: TypeError: Cannot find function tick in object {}.

dawn oar
#

send script

reef briar
dawn oar
#

uhhh

reef briar
#
global.tick(entity => global.entitytick(entity))

/**
 * 
 * @param {Internal.LivingEntity} event 
 */
global.entitytick = entity => {
    if (entity.persistentData.kick == 1){
        entity.persistentData.kick = 0
        entity.triggerAnimation('kickController', 'kick');
    }
}```
dawn oar
#

wheres your entity even

reef briar
#

oh wait

#

yeah

#

fuck

#

my bad

dawn oar
#

lol

#

all g

reef briar
#

[23:04:04] [ERROR] ! reina_startup.js#244: Error in 'StartupEvents.registry': TypeError: Cannot find function tick in object {}.
@dawn oar still same 💀

dawn oar
#

you didnt get rid of the other script did you

#

the global.tick what even is that used for here

#

delete it blobbongoree

reef briar
#

deleted

dawn oar
#

ok now try

reef briar
#

this should work

dawn oar
#

nope

reef briar
#

right?

#

where do I put global functions 😭

dawn oar
#
global.tick(entity => global.entitytick(entity))``` delete this
#

send the script

#

??sendcode

sharp heronBOT
# dawn oar ??sendcode

Send your code here instead of a screenshot

It makes it easier to diagnose your code and help you fix it or make the required changes/additions.

reef briar
#
StartupEvents.registry('entity_type', event => {
    event.create('reina:mfwardenarcher', 'entityjs:animal')
    .addTriggerableAnimationController('kickController', 5, 'kick', 'kick', 'play_once')
    .addAnimationController('exampleController', 5, event => {
        event.thenLoop('idle'); 
        return true;
    });
})

global.tick(entity => global.entitytick(entity))

/**
 * 
 * @param {Internal.LivingEntity} event 
 */
global.entitytick = entity => {
    if (entity.persistentData.kick == 1){
        entity.persistentData.kick = 0
        entity.triggerAnimation('kickController', 'kick');
    }
}```
reef briar
dawn oar
#
StartupEvents.registry('entity_type', event => {
    event.create('reina:mfwardenarcher', 'entityjs:animal')
    .tick(entity => global.entitytick(entity)).addTriggerableAnimationController('kickController', 5, 'kick', 'kick', 'play_once')
    .addAnimationController('exampleController', 5, event => {
        event.thenLoop('idle'); 
        return true;
    });
})

/**
 * 
 * @param {Internal.LivingEntity} event 
 */
global.entitytick = entity => {
    if (entity.persistentData.kick == 1){
        entity.persistentData.kick = 0
        entity.triggerAnimation('kickController', 'kick');
    }
}```
#

tick goes where all the other method overrides go

reef briar
dawn oar
#

lol

reef briar
#

but fixed the main problem I guess

#

yeah so

#

I deleted the idle part

#

now it works

#

I guess it combines 2 animations together

dawn oar
#
.onAddedToWorld(entity => {
            entity.persistentData.kick = 0
        })```
reef briar
#

are we sure this was the problem?

dawn oar
#

no im just sending that so you can use it if needed

#

test it out in the normal controller and make sure its not just some weird thing with the triggerableanimationcontroller

sharp heronBOT
dawn oar
#

oh god

reef briar
#

yeah it plays 2 animations together

dawn oar
#

interesting

#

it shouldnt do that hmmm

#

try the triggerable animation in a normal EntityEvents.hurt server script and see if it works there when you punch it

reef briar
#

maybe that's the problem

dawn oar
#

try going off the same controller maybe

reef briar
dawn oar
#
StartupEvents.registry('entity_type', event => {
    event.create('reina:mfwardenarcher', 'entityjs:animal')
        .tick(entity => global.entitytick(entity))
        .addAnimationController('exampleController', 5, event => {
            event.addTriggerableAnimation('kick', 'kick', 'default');
            event.thenLoop('idle');
            return true;
        })
        .onAddedToWorld(entity => {
            entity.persistentData.kick = 0
        })
        //.addTriggerableAnimationController('kickController', 5, 'kick', 'kick', 'play_once')
})

/**
 * 
 * @param {Internal.LivingEntity} event 
 */
global.entitytick = entity => {
    if (entity.persistentData.kick == 1) {
        entity.persistentData.kick = 0
        entity.triggerAnimation('exampleController', 'kick');
    }
}``` something like this
#

make sure in the tick event its named 'exampleController'

reef briar
#

lets see

dawn oar
#

and if that doesnt work then try only playing the idle animation if the kick animation isnt playing like this js .addAnimationController('exampleController', 5, event => { event.addTriggerableAnimation('kick', 'kick', 'default'); if (event.getController().getCurrentAnimation().animation().name() == 'kick') return event.thenLoop('idle') return true; })

#

also i would put the animation controller into a global event too so you can /kubejs reload

dawn oar
#

guess they have to be in the same controller then

reef briar
#

yeah I guess so

dawn oar
#

for this instance anyways

#

i tested the other controller out and it works, wonder why its not working here hmmm

#

ill have to do more testing with it i guess

reef briar
reef briar
dawn oar
#

bet bet

#

so does this solve the ticket?

#

if you have anymore questions feel free to leave it open

reef briar
#

well I need to do a few testings

#

to be sure

#

then I'll close

dawn oar
#

sounds good heh

reef briar
#

about the head tracking

#

I didn't understand how it works actually

#

I want to make it same as zombie or any entities behaviour

dawn oar
#

head tracker?

#

you mean the look at goal?

reef briar
#

yeah

dawn oar
#

//addGoalSelectors Server Script
EntityJSEvents.addGoalSelectors('kubejs:wyrm', e => {
    let Player = Java.loadClass('net.minecraft.world.entity.player.Player')
    //You have the ability to add pre built goals like so to your entity. (with more to come!)
    e.panic(1, 0.5)
    e.floatSwim(1)
    e.meleeAttack(4, 1, true)
    e.leapAtTarget(3, 0.4)
    e.waterAvoidingRandomStroll(5, 0.4, 0.8)
    e.lookAtEntity(6, Player, 8, 0.8, false)
    e.randomLookAround(7)
})
#

the look at entity is going by class

reef briar
#

oh wait yeah sorry

dawn oar
#
let Player = Java.loadClass('net.minecraft.world.entity.player.Player')
 e.lookAtEntity(6, Player, 8, 0.8, false)```we're loading the player class so any instance of the player will be subject to be looked at
#

i might change this later so people can just type in 'player', 'mob' ect

reef briar
#

oh wait how does geckolib knows the entities head bone

dawn oar
#

it turns the whole entity if the head is not specified i assume

#

you'll have to test that out

reef briar
#

yeah

reef briar
#

well lio

sharp heronBOT
#

Paste version of message.txt from @reef briar

reef briar
#
StartupEvents.registry('entity_type', event => {
    event.create('reina:mfwardenarcher', 'entityjs:animal')
        .tick(entity => global.entitytick(entity))
        .addAnimationController('reinaController', 5, event => {
            event.addTriggerableAnimation('kick', 'kick', 'default');
            event.addTriggerableAnimation('death', 'death', 'default');
            event.addTriggerableAnimation('attack', 'attack', 'default');
            if (event.isMoving()) {
                event.thenLoop("walk");
            }
            else {
                event.thenLoop('idle');
            }
            return true;
        })
        .onAddedToWorld(entity => {
            entity.persistentData.anim = 0
        })
})

/**
 * 
 * @param {Internal.LivingEntity} event 
 */
global.entitytick = entity => {
    if (entity.persistentData.anim !== 0) {
        entity.triggerAnimation('reinaController', entity.persistentData.anim);
        entity.persistentData.anim = 0
    }
}```
dawn oar
#

uh

#

do me a favor

#

and console.log(entity.persistentData.anim)

reef briar
#

it only crashed on server

dawn oar
#

also comment out the triggeranimation line while you do that so it doesnt crash

reef briar
#

without server it runs

reef briar
#

okay

dawn oar
#

is this on the server?

reef briar
#

yes

dawn oar
#

try manually setting it to the string "attack"

reef briar
#

manually?

dawn oar
#

entity.triggerAnimation('reinaController', 'attack');

reef briar
#

oh in the code

dawn oar
#

yea

reef briar
#

yeah crashed

sharp heronBOT
#

Paste version of message.txt from @reef briar

reef briar
#

OH WAIT

#

MY BAD

#

SERVER'S ENTITYJS VERSION IS 0.0.1

dawn oar
#

💀

reef briar
#

yeah

#

well a bug for ya, check the entityjs version on the server.

dawn oar
#

i was about to say id hope that isnt gonna be a thing on a server worry

reef briar
#

if it was I was going to smack my devs to add the mixin to fix it

reef briar
#

last question

#

it works perfectly

#

but

#

we forget about hitboxes.

dawn oar
#

sec

#

i think it's .sized(1,1)

reef briar
#

yes

dawn oar
#

thats for height and width

#

ye

reef briar
#

ye I know that

dawn oar
#

what about hitboxes then?

reef briar
#

how to register them

#

oh wait there was a wiki

dawn oar
#

ah

reef briar
#

they are not in wiki I guess

#

I think it's time to install probejs to this computer

dawn oar
#

you want to register multiple hitboxes? hmmm

#

and yes probejs is your friend heh

reef briar
#

no no no no

dawn oar
#

oh

reef briar
#

just want to increase size of current one

dawn oar
#

then do .sized(3,3) or something

reef briar
#

ooh

#

.sized

#

gotcha

dawn oar
#

yea

#

dont forget theres the full example entity on the wiki page too

#

should have every single overridable method on there

reef briar
#

gosh there is no way to get heigh and width from blockbench right?

#

letme search in internet

dawn oar
#

you could also just summon it and compare it to blocks in game

reef briar
#

oor

dawn oar
#

thats prob what i'd do

reef briar
#

we can divide size by 16

#

in blockbench

#

size can be float right?

dawn oar
#

yes

#

pretty sure

#

looks like it

#

also its width, height, not height width like i said earlier apparently

reef briar
#

lets record a video and hype the chat 😎

dawn oar
#

??closeticket

sharp heronBOT
# dawn oar ??closeticket

Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue! This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You generally should create a new post for unrelated issues.

reef briar
#

yeah I can handle things after this

#

thanks