Egg Spawning

Discussion in 'Plugin Development' started by bronzzze, Apr 7, 2015.

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

    bronzzze

    I have few questions

    1. How to get location where I am looking to spawn something
    screenshot (open)
    [​IMG]

    I tryed this but didn't work:
    Code:
    p.getEyeLocation().getBlock().getLocation()

    2. Question
    PlayerInteractEvent with Mob_egg. How to disable spawning of mob. When I click egg its spawn 2 mobs. How to remove original one.

    3. Question
    How to add to horse saddle. And is there anyway to follow you with setting horse.Owner(player) or horse.setTarget(p) or do I need to use other method.

    Edit:
    Ok I know answer to 1.st question.
    I used this e.getClickedBlock().getLocation()
     
  2. Offline

    nverdier

    1. p.getTargetBlock
    2. Cancel the event (and remove the item)
    3. horse.setEquipment ?
     
    bronzzze likes this.
  3. Offline

    bronzzze

    Everything is working thansk. Only 3rd question
    I want to set so the pet is following to owner and add saddle to it.(horse.setequipment don't work I think)
     
    Last edited: Apr 7, 2015
  4. Code:java
    1. horse.setTarget(livingEntity);
    2. horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
     
  5. Offline

    bronzzze

    I set it
    Code:
       horse.setTarget(p);
    but its not working.



    and another problem I set like this

    Code:
    horse.setColor(Color.BROWN);
    but horse is sometimes spawns as donkey
     
  6. Offline

    Zombie_Striker

    Then you have to set the horse type, and you might have to cast p to a living entity.
     
  7. Offline

    bronzzze

    How to set type to horse?
    and do you mean this if(p instanceof LivingEntity){
     
  8. Offline

    Zombie_Striker

    @bronzzze Do you know what casting is? And if you're using a development kit, you should be able to scroll through all the methods that you horse. contains (which should have a .setType or something like that in there)
     
  9. Offline

    bronzzze

    [​IMG]

    Didnt see you write cast
    So you mean like this
    Code:
    LivingEntity livingEntity = (LivingEntity) p;
     
  10. Offline

    Zombie_Striker

    Its called "setVariant()"
     
  11. Offline

    bronzzze

    Ty.
    Sorry beacuse I am so annoying is this correct
    Code:
        LivingEntity le = (LivingEntity)p;
    
                    horse.setTarget(le);
    
     
  12. Offline

    Zombie_Striker

    It should be correct. Try it and if it works, mark as [solved]
     
  13. Offline

    bronzzze

    I tryed it and didn't work I tryed to add this too:
    Code:
    Player p = e.getPlayer();
    LivingEntity le = (LivingEntity)p;
    AnimalTamer at = (AnimalTamer) p;
    
    horse.setTarget(le);
    horse.setTamed(true);
    horse.setOwner(at);
     
  14. Offline

    Zombie_Striker

    Try debugging.

    Make a method that sends a player a message or that uses System.out.println();

    Have it print out the getTarget,the getOwner ect.
     
  15. Player class extends HumanEntity, which extends LivingEntity. So a Player is actually a LivingEntity.

    Try this to make the horse follow the player: http://bukkit.org/threads/make-a-mob-follow-a-player.351739
     
  16. Offline

    bronzzze

    @FisheyLP
    I used this method
    And got this error:
    Code:
    14:31:01] [Server thread/WARN]: [Bantha] Task #2 for Bantha v1.0 generated an exception
    java.lang.NoClassDefFoundError: org/bukkit/craftbukkit/v1_7_R4/entity/CraftEntity
        at me.bronzzze.pets.EggClickEvent$1.run(EggClickEvent.java:91) ~[?:?]
        at org.bukkit.craftbukkit.v1_8_R1.scheduler.CraftTask.run(CraftTask.java:53) ~[craftbukkit-1.8.jar:git-Bukkit-e87122e]
        at org.bukkit.craftbukkit.v1_8_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:349) [craftbukkit-1.8.jar:git-Bukkit-e87122e]
        at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:653) [craftbukkit-1.8.jar:git-Bukkit-e87122e]
        at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:284) [craftbukkit-1.8.jar:git-Bukkit-e87122e]
        at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:598) [craftbukkit-1.8.jar:git-Bukkit-e87122e]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:506) [craftbukkit-1.8.jar:git-Bukkit-e87122e]
        at java.lang.Thread.run(Unknown Source) [?:1.7.0_75]
    I guess problem is I used in code
    import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
    and server is v1.8 spigot

    Edit:
    Line 91 is
    Code:
                    ((EntityInsentient) ((CraftEntity) e).getHandle()).getNavigation().a(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), f);
     
Thread Status:
Not open for further replies.

Share This Page