I'm making a snowball that when you throw it at someone you switch places. This is how far I've gotten. Code: https://hastebin.com/iziraqelep.java Any suggestions, or help is greatly appreciated. Thank you for your dedication.
@Vistify Hi stuck, I am Tim /End of bad joke You need to use the event that fires when the snowball hits. ProjectileHitEvent I believe (name could be different) Then you can teleport both players. Might need to track the uuid of the snowball though, not sure about that part.
@Vistify As @timtower said, you need to check the ProjectileHitEvent, then check if 'getHitEntity' is null, if it's not null then check if the entity returned by that method is a player and if so teleport the players, remember the save the two locations in the scope and teleport the players to them instead of directly teleporting the players to eachother, otherwise the second player wouldn't get teleported to a new location. To check if the projectile is the snowball you want, you can make a list of type 'Snowball' and then add the snowball to the list when fired in the ProjectileLaunchEvent. (remember to check if it's your snowball before adding it to the list)
Ok, so I just got home and started working on this again and it doesn't do anything. The event is registered in the main class, and I don't get an error in console. I'm very confused.. Code Sample: https://pastebin.com/T0Hicrmp @KarimAKL @timtower
@Vistify damagerE instanceof Snowball if(!(damagerE instanceof Player)) return; They don't go well together.
@Vistify Just a suggestion but instead of naming the entities 'damaged' and 'damager', you could change it to 'victim' and 'attacker', or something like that. It's way easier to look for errors etc.