When you throw a snowball in a entity you go to the entity position, and the entity go to your last postion... Like a switch position!
All you have to do is get the thrower's coords and the entity you hit's coords and the teleport them to eachother
Sorry I'm noob but I did this part: Code: @EventHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { Entity entity = event.getDamager(); if (entity instanceof Snowball) { }
Snowball sball = event.getDamager(); if(sball.getShooter() instanceof Player){ Player p = (Player) sball.getShooter(); Location one = p.getLocation(); Location two = event.getEntity().getLocation(); p.setLocation(two); event.getEntity().setLocation(one);
Code: public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { Snowball sball = event.getDamager(); if(sball.getShooter() instanceof Player){ Player p = (Player) sball.getShooter(); Location one = p.getLocation(); Location two = event.getEntity().getLocation(); p.setLocation(two); event.getEntity().setLocation(one); } } Getting this errors: *On event.getDamager(); = Type mismatch: cannot convert from Entity to Snowball *On setLocation = The method setLocation(Location) is undefined for the type Player
I think you really need to learn java/how to debug code if you can't figure that out...I don't want to just give it to you it's your plugin and you need to learn how anyway.
Iervolino Code: public void onEntityDamageByEntity (EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Snowball) { Snowball sball = (Snowball) event.getDamager(); if (sball.getShooter() instanceof Player && event.getEntity() instanceof LivingEntity) { Player p = (Player) sball.getShooter(); Location one = p.getLocation(); Location two = event.getEntity().getLocation(); p.teleport(two); ((LivingEntity) event.getEntity()).teleport(one); } } }
Iervolino You can't just come on the forums and tell us your plugin isn't working, then just have someone give you code. I bet you took credit for making this, and you didn't even make it, someone else did. If you need someone to do the code for you, go to plugin requests section.
1) I don't request a plugin 2) I don't have a place to put the credits cause this plugin will not be public 3) Plugin Request section is a plugin request area and not a code request
Iervolino Either way, you asked him to just rewrite the code for you instead of you fixing it yourself based on people's advice.