turt2live

Untitled

Oct 14th, 2013
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.03 KB | None | 0 0
  1. package net.shocknetwork.turt2live.kingofthehill.mob;
  2.  
  3. import java.util.List;
  4.  
  5. import net.minecraft.server.v1_6_R3.Entity;
  6. import net.minecraft.server.v1_6_R3.EntityPlayer;
  7. import net.minecraft.server.v1_6_R3.EntityZombie;
  8. import net.minecraft.server.v1_6_R3.World;
  9. import net.shocknetwork.gameapi.GameAPI;
  10. import net.shocknetwork.gameapi.engine.GameSession;
  11. import net.shocknetwork.gameapi.minigame.GameTeam;
  12.  
  13. import org.bukkit.DyeColor;
  14. import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
  15. import org.bukkit.entity.Player;
  16.  
  17. public class KothZombie extends EntityZombie{
  18.  
  19.     public DyeColor color;
  20.  
  21.     public KothZombie(World world){
  22.         super(world);
  23.     }
  24.  
  25.     @Override
  26.     protected Entity findTarget(){
  27.         List<?> near = this.world.players;
  28.         EntityPlayer nearest = null;
  29.         for(Object o : near){
  30.             if(o instanceof EntityPlayer){
  31.                 EntityPlayer pl = (EntityPlayer) o;
  32.  
  33.                 double d3 = 16; // Range
  34.                 double d4 = -1;
  35.                 // START CODE COPY/PASTE FROM NMS
  36.  
  37.                 if(!pl.abilities.isInvulnerable && pl.isAlive()){
  38.                     double d5 = pl.e(locX, locY, locZ);
  39.                     double d6 = d3;
  40.  
  41.                     if(pl.isSneaking()){
  42.                         d6 = d3 * 0.800000011920929D;
  43.                     }
  44.  
  45.                     if(pl.isInvisible()){
  46.                         float f = pl.bx();
  47.  
  48.                         if(f < 0.1F){
  49.                             f = 0.1F;
  50.                         }
  51.  
  52.                         d6 *= (0.7F * f);
  53.                     }
  54.  
  55.                     if((d3 < 0.0D || d5 < d6 * d6) && (d4 == -1.0D || d5 < d4)){
  56.                         d4 = d5;
  57.                         // turt2live start
  58.                         Player player = pl.getBukkitEntity();
  59.                         GameSession session = GameAPI.getGameByPlayer(player);
  60.                         if(session != null){
  61.                             GameTeam team = session.getPlayerTeam(player.getName());
  62.                             if(team != null){
  63.                                 if(team.getTeamDyeColor() != color){
  64.                                     nearest = pl;
  65.                                 }
  66.                             }
  67.                         }
  68.                         // turt2live end
  69.                     }
  70.                 }
  71.  
  72.                 // END CODE COPY/PASTE FROM NMS
  73.             }
  74.         }
  75.         return nearest;
  76.     }
  77.  
  78.     @Override
  79.     public CraftEntity getBukkitEntity(){
  80.         if(this.bukkitEntity == null){
  81.             this.bukkitEntity = new CraftKothZombie(this.world.getServer(), this);
  82.         }
  83.         return this.bukkitEntity;
  84.     }
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment