Advertisement
Guest User

TileEntityRadar

a guest
Jan 31st, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.76 KB | None | 0 0
  1. public class TileEntityRadar extends TileEntity {
  2.    
  3.     protected World worldObj;
  4.     public World radar;
  5.     public AxisAlignedBB boundingBox;
  6.     private int radarRangeHorizontal;
  7.     private int radarRangeVertical;
  8.    
  9.     boolean hasHostiles;
  10.     boolean shouldPrint;
  11.    
  12.     int x;
  13.     int y;
  14.     int z;
  15.     int range;
  16.     int count;
  17.    
  18.     int mode;
  19.    
  20.     int ticksHere;
  21.    
  22.     public final RadarDetectionLogic Radar = new RadarDetectionLogic() {
  23.         public World getRadarWorld()
  24.         {
  25.             return TileEntityRadar.this.worldObj;
  26.         }
  27.         public int getRadarX()
  28.         {
  29.             return TileEntityRadar.this.xCoord;
  30.         }
  31.         public int getRadarY()
  32.         {
  33.             return TileEntityRadar.this.yCoord;
  34.         }
  35.         public int getRadarZ()
  36.         {
  37.             return TileEntityRadar.this.zCoord;
  38.         }
  39.         public int getRadarRange() {
  40.             // TODO Auto-generated method stub
  41.             return TileEntityRadar.this.range;
  42.         }
  43.        
  44.     };
  45.    
  46.     public TileEntityRadar(int range) {
  47.         super();
  48.         this.range = range;
  49.         x = this.xCoord;
  50.         y = this.yCoord;
  51.         z = this.zCoord;
  52.         this.mode = 1;
  53.         this.markDirty();
  54.         // TODO Auto-generated constructor stub
  55.     }
  56.    
  57.     // Get values  
  58.     public boolean getDanger(int range) {
  59.         boolean flag = Radar.getDanger();
  60.         return flag;
  61.     }
  62.    
  63.     public int getEntityCount(int range) {
  64.         int count = Radar.getEntityCount();
  65.         return count;
  66.     }
  67.    
  68.     public void updateEntity() {
  69.         Radar.updateRadar(range);
  70.         Minecraft.getMinecraft().thePlayer.sendChatMessage("We have updated the Radar. This is tick " + ticksHere + " of such event.");
  71.         ticksHere++;
  72.         boolean dangerous = this.getDanger(range);
  73.         count = this.getEntityCount(range);
  74.  
  75.         if (dangerous) {
  76.             hasHostiles = true;
  77.             Minecraft.getMinecraft().thePlayer.sendChatMessage("The Radar " + x + ", " + y + ", " + z + " of range " + range + "has detected a total of " + count + " registered hostile entities in range.");
  78.             if (shouldPrint) {
  79.                
  80.                 shouldPrint = false;
  81.             }
  82.         } else {
  83.             hasHostiles = false;
  84.             Minecraft.getMinecraft().thePlayer.sendChatMessage("No hostilities in range.");
  85.         }
  86.         if (hasHostiles) {
  87.             this.getBlockType().setLightLevel(15);
  88.         } else {
  89.             this.getBlockType().setLightLevel(0);
  90.         }
  91.     }
  92.  
  93.     public void printInfo() {
  94.         int i, j, k;
  95.         if (mode == 1) {
  96.             i = this.Radar.getRadarX();
  97.             j = this.Radar.getRadarY();
  98.             k = this.Radar.getRadarZ();
  99.         } else {
  100.             i = x;
  101.             j = y;
  102.             k = z;
  103.         }
  104.         Minecraft.getMinecraft().thePlayer.sendChatMessage("A new instance of DetectionLogic has been created. It's range is " +range+ ".");
  105.         // TODO Auto-generated method stub
  106.         Minecraft.getMinecraft().thePlayer.sendChatMessage("The Radar " + i + ", " + j + ", " + k + " of range " + range + " has detected a total of " + count + " registered hostile entities in range.");
  107.         return;
  108.     }
  109.  
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement