Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 2.78 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.util.Random;
  4.  
  5. public class BlockBattery extends BlockContainer {
  6.  
  7.     public BlockBattery(int i, int j, Material material) {
  8.         super(i, j, material);
  9.         updateCounter = 0;
  10.         setTickOnLoad(true);       
  11.     }
  12.  
  13.     protected TileEntity getBlockEntity() {
  14.         return new TileEntityBattery();
  15.     }
  16.    
  17.     public int tickRate() {
  18.         return 2;
  19.     }
  20.    
  21.     public void updateTick(World world, int i, int j, int k, Random random) {
  22.         TileEntityBattery tileentity = (TileEntityBattery)world.getBlockTileEntity(i, j, k);
  23.         updateCounter = (updateCounter + 1) % 20;
  24.         tileentity.currentState = tileentity.poweredTick[updateCounter];
  25.         if (tileentity.currentState != tileentity.prevState) {
  26.             if (tileentity.enabledFace[0]) world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID);
  27.             if (tileentity.enabledFace[1]) world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
  28.             if (tileentity.enabledFace[2]) world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
  29.             if (tileentity.enabledFace[3]) world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
  30.             if (tileentity.enabledFace[4]) world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
  31.             if (tileentity.enabledFace[5]) world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
  32.             tileentity.prevState = tileentity.currentState;            
  33.         }
  34.     }
  35.    
  36.     public boolean isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l) {
  37.         TileEntityBattery tileentity = (TileEntityBattery)iblockaccess.getBlockTileEntity(i, j, k);
  38.         return tileentity.currentState && tileentity.enabledFace[l];
  39.     }
  40.  
  41.     public boolean isIndirectlyPoweringTo(World world, int i, int j, int k, int l) {
  42.         TileEntityBattery tileentity = (TileEntityBattery)world.getBlockTileEntity(i, j, k);
  43.         return tileentity.currentState && tileentity.enabledFace[l];       
  44.     }
  45.    
  46.     public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
  47.         // Open GUI to Configure
  48.         return false;
  49.     }
  50.    
  51.     private int updateCounter;
  52. }
  53.  
  54.  
  55. package net.minecraft.src;
  56.  
  57. public class TileEntityBattery extends TileEntity {
  58.  
  59.     public TileEntityBattery() {
  60.         enabledFace = new boolean[] {
  61.                 false, false, false, false, false, false
  62.         };
  63.         poweredTick = new boolean[] {
  64.                 false, false, false, false, false, false, false, false, false, false,
  65.                 false, false, false, false, false, false, false, false, false, false
  66.         };
  67.         currentState = false;
  68.         prevState = false;
  69.     }
  70.    
  71.     public void readFromNBT(NBTTagCompound nbttagcompound) {
  72.         super.readFromNBT(nbttagcompound);
  73.         //
  74.     }
  75.    
  76.     public void writeToNBT(NBTTagCompound nbttagcompound) {
  77.         super.writeToNBT(nbttagcompound);
  78.         //
  79.     }
  80.    
  81.     public boolean[] enabledFace;
  82.     public boolean[] poweredTick;
  83.     public boolean currentState;
  84.     public boolean prevState;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement