Advertisement
Mister-Yaoi

Untitled

Oct 14th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.00 KB | None | 0 0
  1. /**
  2.      * Called when the block is placed in the world.
  3.      */
  4.     public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
  5.     {
  6.         int var7 = determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase);
  7.        
  8.         par1World.setBlockMetadataWithNotify(par2, par3, par4, var7, 2);
  9.         boolean var8 = this.isGettingInput(par1World, par2, par3, par4, var7);
  10.        
  11.         if (var8)
  12.         {
  13.             par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 2);
  14.         }
  15.        
  16.         par1World.setBlockMetadataWithNotify(par2, par3, par4, var7, 2);
  17.     }
  18.    
  19.     /**
  20.      * Ticks the block if it's been scheduled
  21.      */
  22.     public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
  23.     {
  24.         int var6 = par1World.getBlockMetadata(par2, par3, par4);
  25.  
  26.         if (!this.func_94476_e(par1World, par2, par3, par4, var6))
  27.         {
  28.             boolean var7 = this.isGettingInput(par1World, par2, par3, par4, var6);
  29.  
  30.             if (this.isPowered && !var7)
  31.             {
  32.                 par1World.setBlock(par2, par3, par4, Block.directionalIdle.blockID, var6, 2);
  33.             }
  34.             else if (!this.isPowered && var7)
  35.             {
  36.                 par1World.setBlock(par2, par3, par4, Block.directionalActive.blockID, var6, 2);
  37.             }
  38.            
  39.             par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
  40.             par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
  41.             par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID);
  42.             par1World.notifyBlocksOfNeighborChange(par2 - 1, par3, par4, this.blockID);
  43.             par1World.notifyBlocksOfNeighborChange(par2 + 1, par3, par4, this.blockID);
  44.             par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - 1, this.blockID);
  45.             par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, this.blockID);
  46.         }
  47.     }
  48.    
  49.     /**
  50.      * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
  51.      * their own) Args: x, y, z, neighbor blockID
  52.      */
  53.     public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
  54.     {
  55.         this.func_94479_f(par1World, par2, par3, par4, par5);
  56.     }
  57.    
  58.     protected void func_94479_f(World par1World, int par2, int par3, int par4, int par5)
  59.     {
  60.         int var6 = par1World.getBlockMetadata(par2, par3, par4);
  61.  
  62.         if (!this.func_94476_e(par1World, par2, par3, par4, var6))
  63.         {
  64.             boolean var7 = this.isGettingInput(par1World, par2, par3, par4, var6);
  65.  
  66.             if ((this.isPowered && !var7 || !this.isPowered && var7) && !par1World.isBlockTickScheduledThisTick(par2, par3, par4, this.blockID))
  67.             {
  68.                 byte var8 = -1;
  69.  
  70.                 if (this.func_83011_d(par1World, par2, par3, par4, var6))
  71.                 {
  72.                     var8 = -3;
  73.                 }
  74.                 else if (this.isPowered)
  75.                 {
  76.                     var8 = -2;
  77.                 }
  78.  
  79.                 par1World.scheduleBlockUpdateWithPriority(par2, par3, par4, this.blockID, this.func_94481_j_(var6), var8);
  80.             }
  81.         }
  82.     }
  83.    
  84.     public boolean func_83011_d(World par1World, int par2, int par3, int par4, int par5)
  85.     {
  86.         int var6 = getDirection(par5);
  87.  
  88.         if (isDirectionalBlockID(par1World.getBlockId(par2 - Direction.offsetX[var6], par3, par4 - Direction.offsetZ[var6])))
  89.         {
  90.             int var7 = par1World.getBlockMetadata(par2 - Direction.offsetX[var6], par3, par4 - Direction.offsetZ[var6]);
  91.             int var8 = getDirection(var7);
  92.             return var8 != var6;
  93.         }
  94.         else
  95.         {
  96.             return false;
  97.         }
  98.     }
  99.    
  100.     public boolean func_94476_e(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
  101.     {
  102.         return false;
  103.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement