[Updated Code] Ok so now why cant i ride Wolves

Discussion in 'Plugin Development' started by finalblade1234, Jan 18, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    finalblade1234

    Ok so why cant i ride woves now:
    Code:
    package org.hopto.finalcraft.finalblade1234;
     
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.LivingEntity;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Wolf;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
     
    public class SquatListner implements Listener {
    @EventHandler
        public void onMobSpawn(PlayerInteractEntityEvent event){
     
        Player p = event.getPlayer();
        Entity mob = event.getRightClicked();
        if(p.getItemInHand().getType() == Material.BLAZE_ROD){
            if(mob instanceof Wolf){
            @SuppressWarnings("unused")
            Location loc = (Location) p.getLocation();
                mob.setPassenger(p);
               
                p.setHealth(20);
              ((LivingEntity) mob).addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 900000000, 4));
              ((LivingEntity) mob).addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 900000000, 2));
              ((LivingEntity) mob).addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 900000000, 2));
              ((LivingEntity) mob).addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 900000000, 5));
                //lawl
                    p.sendMessage("You just mounted a Wolf");
                    if(mob.getPassenger().equals(p)){
                        p.sendMessage("testing");
            }
        }
    }
    }
     
    }
    ok so it gets to all of the code but it kicks me off the wolf as soon as im on it?
    it goes:
    You just mounted a wolf!
    testing
    You just mounted a wolf!
    why does it do it twice

    Oh and BTW this Is NOT a repost...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  2. Offline

    t7seven7t

    Just move the passenger check you use for "testing" to before you set the wolf's passenger.

    Code:
    if (mob instanceof Wolf && !mob.getPassenger().equals(p)) {
     
  3. Offline

    fireblast709

    finalblade1234 works fine for me. Maybe another plugin is causing this
     
  4. Offline

    finalblade1234

    oh yes i do test it on my main server
    but my testing server doesnt spawn wolves? not even with spawn eggs
    ill try updating on my testing server
    oh and on my other server i use SpiGot not CraftBukkit
     
  5. Offline

    t7seven7t

    finalblade1234 Does your test server have spawn-animals enabled in the server.properties or another plugin blocking them from spawning?
     
  6. Offline

    finalblade1234

    ok i fixed wolves spawning
    and YAY it works :D
    now how to i make players controll them?
    whould get the the players X Y Z Yaw and Pitch and tp the mod to it?
     
  7. Offline

    t7seven7t

  8. Offline

    fireblast709

    Well that is the hard part. You probably have to fiddle around with net.minecraft.server code for that (maybe create an EntityWolf that behaves like a pig?)
     
  9. Offline

    tommycake50

    yeah but its not as easy to get when to walk forward fire :I.
    if impossible.
    and i would like to know where you are using loc(im sure location takes up a few bytes of memory).
    @SuppressWarnings("unused")
    Location loc = (Location) p.getLocation();
     
Thread Status:
Not open for further replies.

Share This Page