Advertisement
Guest User

FishingRook

a guest
Apr 28th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.78 KB | None | 0 0
  1. package me.filipenock.Addon.Habilidades;
  2.  
  3. import org.bukkit.craftbukkit.v1_8_R3.*;
  4. import org.bukkit.entity.*;
  5. import org.bukkit.entity.Entity;
  6.  
  7. import me.filipenock.Addon.Main;
  8.  
  9. import org.bukkit.*;
  10. import org.bukkit.craftbukkit.v1_8_R3.entity.*;
  11. import net.minecraft.server.v1_8_R3.*;
  12.  
  13. public class CopyOfFishingHook extends EntityFishingHook
  14. {
  15.     private Snowball sb;
  16.     private EntitySnowball controller;
  17.     public int a;
  18.     public EntityHuman owner;
  19.     public Entity hooked;
  20.     public boolean lastControllerDead;
  21.     public boolean isHooked;
  22.    
  23.     public CopyOfFishingHook(final CraftWorld world, final EntityHuman entityhuman) {
  24.         super((net.minecraft.server.v1_8_R3.World)((CraftWorld)world).getHandle(), entityhuman);
  25.         this.owner = entityhuman;
  26.     }
  27.    
  28.     protected void c() {
  29.     }
  30.    
  31.     public void h() {
  32.         if (!this.lastControllerDead && this.controller.dead) {
  33.             ((Player)this.owner.getBukkitEntity()).sendMessage(ChatColor.GREEN + "You are now hooked!");
  34.         }
  35.         this.lastControllerDead = this.controller.dead;
  36.         for (final Entity entity : this.controller.world.getWorld().getEntities()) {
  37.             if (!(entity instanceof Firework) && entity.getEntityId() != this.getBukkitEntity().getEntityId() && entity.getEntityId() != this.owner.getBukkitEntity().getEntityId() && entity.getEntityId() != this.controller.getBukkitEntity().getEntityId()) {
  38.                 if (entity.getLocation().distance(this.controller.getBukkitEntity().getLocation()) >= 2.0) {
  39.                     if (!(entity instanceof Player)) {
  40.                         continue;
  41.                     }
  42.                     if (((Player)entity).getEyeLocation().distance(this.controller.getBukkitEntity().getLocation()) >= 2.0) {
  43.                         continue;
  44.                     }
  45.                 }
  46.                 this.controller.die();
  47.                 this.hooked = entity;
  48.                 this.isHooked = true;
  49.                 this.locX = entity.getLocation().getX();
  50.                 this.locY = entity.getLocation().getY();
  51.                 this.locZ = entity.getLocation().getZ();
  52.                 this.motX = 0.0;
  53.                 this.motY = 0.04;
  54.                 this.motZ = 0.0;
  55.             }
  56.         }
  57.         try {
  58.             this.locX = this.hooked.getLocation().getX();
  59.             this.locY = this.hooked.getLocation().getY();
  60.             this.locZ = this.hooked.getLocation().getZ();
  61.             this.motX = 0.0;
  62.             this.motY = 0.04;
  63.             this.motZ = 0.0;
  64.             this.isHooked = true;
  65.         }
  66.         catch (Exception e) {
  67.             if (this.controller.dead) {
  68.                 this.isHooked = true;
  69.             }
  70.             this.locX = this.controller.locX;
  71.             this.locY = this.controller.locY;
  72.             this.locZ = this.controller.locZ;
  73.         }
  74.     }
  75.    
  76.     public void die() {
  77.     }
  78.    
  79.     public void remove() {
  80.         super.die();
  81.     }
  82.    
  83.     public void spawn(final Location location) {
  84.         this.sb = (Snowball)this.owner.getBukkitEntity().launchProjectile((Class)Snowball.class);
  85.         this.controller = ((CraftSnowball)this.sb).getHandle();
  86.         final PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[] { this.controller.getId() });
  87.         Player[] onlinePlayers;
  88.         for (Player p : Main.getPlugin().getServer().getOnlinePlayers()) {
  89.             ((CraftPlayer)p).getHandle().playerConnection.sendPacket((Packet)packet);
  90.         }
  91.         ((CraftWorld)location.getWorld()).getHandle().addEntity((net.minecraft.server.v1_8_R3.Entity)this);
  92.     }
  93.    
  94.     public boolean isHooked() {
  95.         return this.isHooked;
  96.     }
  97.    
  98.     public void setHookedEntity(final Entity damaged) {
  99.         this.hooked = damaged;
  100.     }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement