Carpet

Carpet

2M Downloads

Snowballs, Eggs, and Arrows aren't considered entities.

poombus opened this issue ยท 7 comments

commented

Don't know if this is a bug, an oversight, or what, so bear with me.

Snowballs, eggs, arrows (which I'll just generalize as projectiles) can be called as entities in vanilla. However, when I try to perform functions through them as entities, they aren't considered entities.

I did this by giving the projectiles a score based on how many ticks it's been active in the world, then using a "for" loop to assign all entities with that age score (which should only be projectiles) to the variable "_".

Doing print(_); gives me the name of the entity (bunch of letters and numbers with occasional dashes), but trying access their motion vectors returns errors.

commented

Oh, and I think this should be relevant. What I'm trying to do is to translate the projectiles' motion vectors into the target's (whoever gets hit by the projectile) motion vectors.

Example, I throw a snowball with motion [1,0,0]. The player that's hit by the snowball will also move [1,0,0].

Would it be possible to add an event that supports all projectile collisions (as far as I can tell, __on_player_takes_damage only works with arrows, and __on_player_deals_damage doesn't say where the damage comes from).

Basically, what I'm trying to say is that there is (again, from what I can tell) no way to track projectiles.

commented

idk about that. when I do __on_tick->print(entity_selector('@e[type=snowball]')) it works pretty good

commented

its possible that some entity endpoints miss some relevant classes. Is motion the only thing that you can't get from them? Also keep in mind that it might be possible that when entity collides their motion at that point could have been zeroed. Haven't tested that so can't say for certain

commented

regarding taking damage - will check whats reported with eggs and snowballs, but as far as I know if the damage is 0 it is not reported in general

Regarding dealing damage - its all caused by player. I would need to check what happens with projectiles. It might be logged in statistics though

commented

no wait im not sure about statistics. cos if not the HC snowball datapack wouldn't need the hackfix with all the hermit names.coded for specifically. Luckily for them at the time there weren't too many names to incorporate, or it would have gotten too large too quick. Im 77.2% certain that won't work.

commented

tried in a flat empty world with
script run print_motion() -> for(entity_list('!players'), print(_~'motion'))
then
script event add_to tick print_motion
arrows, snowballs and thrown eggs printed their motion vectors
Not sure what you are trying to do - maybe you can share here.

commented

I figured it out. I guess I was doing something wrong. I turned mob spawning off and did what you suggested. The snowballs, arrows, fishing bobbers, etc did show up and I could interact with them through carpet. Sorry for sending you on a goose chase lol. (but I still would like an event the detects when snowballs or eggs collide with an entity, if that is even possible)