Guest User

Detection Radar

a guest
Jan 31st, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. public abstract class RadarDetectionLogic {
  2.    
  3.     public abstract World getRadarWorld();
  4.  
  5.     public abstract int getRadarX();
  6.  
  7.     public abstract int getRadarY();
  8.  
  9.     public abstract int getRadarZ();
  10.    
  11.     public abstract int getRadarRange();
  12.    
  13.     // Radar Specs
  14.     int RadarRange = 48;
  15.     double RadarRangeHoriz;
  16.     double RadarRangeVerti;
  17.     int RadarRangeHorizintal;
  18.     int RadarRangeVertical;
  19.    
  20.     // Radar Scan results
  21.     boolean dangerous;
  22.     int count;
  23.    
  24.     public void updateRadar(int range) {
  25.         // TODO Auto-generated method stub
  26.         boolean active;
  27.         double x = this.getRadarX();
  28.         double y = this.getRadarY();
  29.         double z = this.getRadarZ();
  30.         if (range > 0 && range >= 16) {
  31.             // Let's make sure it can detect entities at least a chunk away.
  32.             RadarRange = range;
  33.         }
  34.         this.RadarRangeHoriz = RadarRange*2;
  35.         this.RadarRangeVerti = RadarRange;
  36.         int count = this.getRadarWorld().getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(x, y, z, x+1, y+1, z+1).expand(this.RadarRangeHoriz, this.RadarRangeVerti, this.RadarRangeHoriz)).size();
  37.         if (count > 0) {
  38.             dangerous = true;
  39.             this.count = count;
  40.         } else {
  41.             dangerous = false;
  42.             this.count = 0;
  43.         }
  44.         Minecraft.getMinecraft().thePlayer.sendChatMessage(x + " " + y + " " + z + ";range:" + range);
  45.     }
  46.    
  47.     public boolean getDanger() {
  48.         return dangerous;
  49.     }
  50.    
  51.     public int getEntityCount() {
  52.         return count;
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment