Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.19 KB | None | 0 0
  1. public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_)
  2.     {
  3.         return super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && this.canBlockStay(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_);
  4.     }
  5.  
  6.     /**
  7.      * is the block grass, dirt or farmland
  8.      */
  9.     protected boolean canPlaceBlockOn(Block p_149854_1_)
  10.     {
  11.         return p_149854_1_ == Blocks.grass || p_149854_1_ == Blocks.dirt || p_149854_1_ == Blocks.farmland;
  12.     }
  13.  
  14.     /**
  15.      * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
  16.      * their own) Args: x, y, z, neighbor Block
  17.      */
  18.     public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
  19.     {
  20.         super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_);
  21.         this.checkAndDropBlock(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_);
  22.     }
  23.  
  24.     /**
  25.      * Ticks the block if it's been scheduled
  26.      */
  27.     public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
  28.     {
  29.         this.checkAndDropBlock(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
  30.     }
  31. protected void checkAndDropBlock(World p_149855_1_, int p_149855_2_, int p_149855_3_, int p_149855_4_)
  32.     {
  33.         if (!this.canBlockStay(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_))
  34.         {
  35.             this.dropBlockAsItem(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_, p_149855_1_.getBlockMetadata(p_149855_2_, p_149855_3_, p_149855_4_), 0);
  36.             p_149855_1_.setBlock(p_149855_2_, p_149855_3_, p_149855_4_, getBlockById(0), 0, 2);
  37.         }
  38.     }
  39.  
  40.     /**
  41.      * Can this block stay at this position.  Similar to canPlaceBlockAt except gets checked often with plants.
  42.      */
  43.     public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_)
  44.     {
  45.         return  p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_).canSustainPlant(p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_, ForgeDirection.UP, this);
  46.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement