Guest User

Untitled

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