Advertisement
Guest User

Untitled

a guest
May 5th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. private Snowball sb;
  2. private EntitySnowball controller;
  3. public int a;
  4. public EntityHuman owner;
  5. public Entity hooked;
  6. public boolean lastControllerDead;
  7. public boolean isHooked;
  8.  
  9. public CopyOfFishingHook(org.bukkit.World world, EntityHuman entityhuman)
  10. {
  11. super(((CraftWorld)world).getHandle(), entityhuman);
  12. this.owner = entityhuman;
  13. }
  14.  
  15. protected void c() {}
  16.  
  17. public void h()
  18. {
  19. if ((!this.lastControllerDead) && (this.controller.dead)) {
  20. ((Player)this.owner.getBukkitEntity()).sendMessage(Prefix.pre + "§aSeu gancho prendeu em alguma coisa!");
  21. }
  22. this.lastControllerDead = this.controller.dead;
  23. for (Entity entity : this.controller.world.getWorld().getEntities()) {
  24. if ((!(entity instanceof Firework)) && (entity.getEntityId() != getBukkitEntity().getEntityId()) && (entity.getEntityId() != this.owner.getBukkitEntity().getEntityId()) && (entity.getEntityId() != this.controller.getBukkitEntity().getEntityId()) && ((entity.getLocation().distance(this.controller.getBukkitEntity().getLocation()) < 2.0D) || (((entity instanceof Player)) && (((Player)entity).getEyeLocation().distance(this.controller.getBukkitEntity().getLocation()) < 2.0D))))
  25. {
  26. this.controller.die();
  27. this.hooked = entity;
  28. this.isHooked = true;
  29. this.locX = entity.getLocation().getX();
  30. this.locY = entity.getLocation().getY();
  31. this.locZ = entity.getLocation().getZ();
  32. this.motX = 0.0D;
  33. this.motY = 0.04D;
  34. this.motZ = 0.0D;
  35. }
  36. }
  37. try
  38. {
  39. this.locX = this.hooked.getLocation().getX();
  40. this.locY = this.hooked.getLocation().getY();
  41. this.locZ = this.hooked.getLocation().getZ();
  42. this.motX = 0.0D;
  43. this.motY = 0.04D;
  44. this.motZ = 0.0D;
  45. this.isHooked = true;
  46. }
  47. catch (Exception e)
  48. {
  49. if (this.controller.dead) {
  50. this.isHooked = true;
  51. }
  52. this.locX = this.controller.locX;
  53. this.locY = this.controller.locY;
  54. this.locZ = this.controller.locZ;
  55. }
  56. }
  57.  
  58. public void die() {}
  59.  
  60. public void remove()
  61. {
  62. super.die();
  63. }
  64.  
  65. @SuppressWarnings("deprecation")
  66. public void spawn(Location location)
  67. {
  68. this.sb = ((Snowball)this.owner.getBukkitEntity().launchProjectile(Snowball.class));
  69. this.controller = ((CraftSnowball)this.sb).getHandle();
  70.  
  71. PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[] { this.controller.getId() });
  72. for (Player p : Bukkit.getOnlinePlayers()) {
  73. ((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
  74. }
  75. ((CraftWorld)location.getWorld()).getHandle().addEntity(this);
  76. }
  77.  
  78. public boolean isHooked()
  79. {
  80. return this.isHooked;
  81. }
  82.  
  83. public void setHookedEntity(Entity damaged)
  84. {
  85. this.hooked = damaged;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement