Advertisement
Guest User

TileEntityCoil

a guest
Aug 15th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. package net.secknv.nkmod.tileentity;
  2.  
  3. import net.minecraft.block.properties.PropertyBool;
  4. import net.minecraft.entity.player.EntityPlayer;
  5. import net.minecraft.tileentity.TileEntity;
  6. import net.minecraft.tileentity.TileEntityCommandBlock;
  7. import net.minecraft.tileentity.TileEntityMobSpawner;
  8. import net.minecraft.util.ITickable;
  9. import net.minecraft.util.math.BlockPos;
  10. import net.minecraft.world.World;
  11.  
  12. public class TileEntityCoil extends TileEntity implements ITickable{
  13.    
  14.     private int ticks = 1;
  15.     private double activatingRangeFromPlayer = 3;
  16.     public boolean messUpCompass = false;
  17.    
  18.     public World getCoilWorld()
  19.     {
  20.         return TileEntityCoil.this.worldObj;
  21.     }
  22.    
  23.     public BlockPos getCoilPosition()
  24.     {
  25.         return TileEntityCoil.this.pos;
  26.     }
  27.    
  28.     private boolean isPlayerInRange()
  29.     {
  30.         BlockPos blockpos = this.getCoilPosition();
  31.         return this.getCoilWorld().isAnyPlayerWithinRangeAt((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D, (double)this.activatingRangeFromPlayer);
  32.     }
  33.  
  34.     @Override
  35.     public void update() {
  36.        
  37.         if(ticks == 20){
  38.            
  39.             this.messUpCompass = false;
  40.            
  41.             if(this.isPlayerInRange() && block is redstone activated){
  42.                 this.messUpCompass = true;
  43.             }
  44.             ticks = 1;
  45.         }
  46.         ticks++;
  47.     }
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement