So for a mod that I'm making, I need to track a custom mob using variables. I already have the tracking part, and the variable that is assigned to the mob can be used to set velocities, held items, effects, etc. My question is, after I lose tracking of it momentarily, and the variable gets reset to null/0, are there any combinations of functions I can use to regain tracking of it and reassign the variable to the mob, so I can change it again?
I have already tried Entity.getAll(); with a for loop testing Entity.getNameTag on the selected mob, but it never detects the custom mob as having a name. If anyone can figure out how to convert an entity's unique ID into a mob tracking variable, that would work too.
When I say a tracking variable, I mean how you can use:
customMob=Level.spawnMob(x,y,z,mobID);
setVelY(customMob,99);
to set the velocity of a specific mob.
I don't want to use attackHook(), since I am using the tracking to make my mob immovable and invulnerable, and they player could pour lava and kill the mob without attacking first.
With more testing, I found that Entity.getAll() in conjunction with a clientMessage(Entity.getNameTag(mobs[i])); inside a standard for loop prints out all names correctly, but
if (Entity.getNameTag(mobs[i])=="CustomName") {
print("Found it!");
}
does not, in fact, ever get executed. Am I missing something really big here?
That could be one way, but the way I meant it was recovering the mob in a variable after rejoining. Anyway, I solved it by myself, the Entity.getNameTag method does work, but I just spelled the name slightly wrong of the mob
Solved!
So for a mod that I'm making, I need to track a custom mob using variables. I already have the tracking part, and the variable that is assigned to the mob can be used to set velocities, held items, effects, etc. My question is, after I lose tracking of it momentarily, and the variable gets reset to null/0, are there any combinations of functions I can use to regain tracking of it and reassign the variable to the mob, so I can change it again?
I have already tried Entity.getAll(); with a for loop testing Entity.getNameTag on the selected mob, but it never detects the custom mob as having a name. If anyone can figure out how to convert an entity's unique ID into a mob tracking variable, that would work too.
When I say a tracking variable, I mean how you can use:
customMob=Level.spawnMob(x,y,z,mobID);
setVelY(customMob,99);
to set the velocity of a specific mob.
I don't want to use attackHook(), since I am using the tracking to make my mob immovable and invulnerable, and they player could pour lava and kill the mob without attacking first.
Thanks for helping everyone who responds.
I have nothing to say...
With more testing, I found that Entity.getAll() in conjunction with a clientMessage(Entity.getNameTag(mobs[i])); inside a standard for loop prints out all names correctly, but
if (Entity.getNameTag(mobs[i])=="CustomName") {
print("Found it!");
}
does not, in fact, ever get executed. Am I missing something really big here?
I have nothing to say...
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumDo you man saving the variable after leaving the world?
That could be one way, but the way I meant it was recovering the mob in a variable after rejoining. Anyway, I solved it by myself, the Entity.getNameTag method does work, but I just spelled the name slightly wrong of the mob
I have nothing to say...
-
View User Profile
-
View Posts
-
Send Message
Curse Premiumokay