Extended entity appear in floor

Discussion in 'Plugin Development' started by Someone_Like_You, May 14, 2014.

Thread Status:
Not open for further replies.
  1. i extended entityPig and now when I spawn the entity he appear inside the floor... (so his body in the floor and bit of his head is out..) any help?
     
  2. Offline

    zDylann

    Err.. Try spawning the entity a few blocks higher so its not in the floor?
     
  3. zDylann Im spawning the pig in player eye location and then settings its velocity to his direction, its work if the player aim straight at ground, if his aiming above, the entity start derping in the floor...
     
  4. pig class:
    Code:java
    1. public class RandomPig extends EntityPig{
    2.  
    3. public RandomPig(World world) {
    4. super(world);
    5. try{
    6. Field bField = PathfinderGoalSelector.class.getDeclaredField("b");
    7. bField.setAccessible(true);
    8. Field cField = PathfinderGoalSelector.class.getDeclaredField("c");
    9. cField.setAccessible(true);
    10. bField.set(goalSelector, new UnsafeList<PathfinderGoalSelector>());
    11. bField.set(targetSelector, new UnsafeList<PathfinderGoalSelector>());
    12. cField.set(goalSelector, new UnsafeList<PathfinderGoalSelector>());
    13. cField.set(targetSelector, new UnsafeList<PathfinderGoalSelector>());
    14. }catch(Exception exc){
    15. exc.printStackTrace();
    16. }
    17. }
    18.  
    19.  
    20. protected Item getLoot() {
    21. return null;
    22. }
    23.  
    24. protected void dropDeathLoot(boolean flag, int i) {
    25. }
    26. }


    how I shoot the pig :
    Code:java
    1. RandomPig rPig = new RandomPig(((CraftWorld) e.getPlayer().getWorld()).getHandle());
    2. rPig.setPosition(e.getPlayer().getEyeLocation().getX(), e.getPlayer().getEyeLocation().getY(), e.getPlayer()
    3. .getEyeLocation().getZ());
    4. ((CraftWorld) e.getPlayer().getWorld()).getHandle().addEntity(rPig);
    5. rPig.getBukkitEntity().setVelocity(e.getPlayer().getEyeLocation().getDirection().multiply(1));
     
Thread Status:
Not open for further replies.

Share This Page