Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BlockARField extends Block implements ITileEntityProvider
- {
- @SideOnly(Side.CLIENT)
- private IIcon field_149824_a;
- @SideOnly(Side.CLIENT)
- private IIcon field_149823_b;
- private static final String __OBFID = "CL_00000241";
- public int compostTimer;
- public boolean hasCompost;
- public BlockARField()
- {
- super(Material.ground);
- this.setTickRandomly(true);
- this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F);
- this.setLightOpacity(255);
- this.setBlockName("ARField");
- this.setBlockTextureName("ARField");
- this.compostTimer = 0;
- this.hasCompost = false;
- this.setCreativeTab(ARMain.TabARBlocks);
- }
- public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
- {
- return AxisAlignedBB.getBoundingBox((double)(p_149668_2_ + 0), (double)(p_149668_3_ + 0), (double)(p_149668_4_ + 0), (double)(p_149668_2_ + 1), (double)(p_149668_3_ + 1), (double)(p_149668_4_ + 1));
- }
- public boolean isOpaqueCube()
- {
- return false;
- }
- public boolean renderAsNormalBlock()
- {
- return false;
- }
- @SideOnly(Side.CLIENT)
- public IIcon getIcon(int p_149691_1_, int p_149691_2_)
- {
- return p_149691_1_ == 1 ? (p_149691_2_ > 0 ? this.field_149824_a : this.field_149823_b) : Blocks.dirt.getBlockTextureFromSide(p_149691_1_);
- }
- public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer player, int par6, float par7, float par8, float par9)
- {
- if (par1World.isRemote)
- {
- Item item = player.inventory.getCurrentItem().getItem();
- if(item == ItemHandler.CompostBucket)
- {
- this.hasCompost = true;
- return true;
- }
- else
- {
- return false;
- }
- }
- return false;
- }
- @Override
- public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
- {
- if (!this.func_149821_m(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_) && !p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_ + 1, p_149674_4_))
- {
- int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
- if (l > 0)
- {
- p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l - 1, 2);
- }
- else if (!this.func_149822_e(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
- {
- p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.dirt);
- }
- }
- else
- {
- p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, 7, 2);
- }
- /*
- if(!p_149674_1_.isRemote)
- {
- long compostTime = p_149674_1_.getWorldTime() - p_149674_1_.getWorldTime() + this.compostTimer;
- if(compostTime < 10 && !hasCompost)
- {
- this.compostTimer++;
- }
- if(compostTime >= 10 && !hasCompost)
- {
- p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.dirt);
- }
- if(this.hasCompost)
- {
- //p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, 7, 2);
- }
- System.out.println("has compost: "+this.hasCompost);
- System.out.println("Timer: "+compostTime);
- }*/
- }
- @Override
- public void onFallenUpon(World p_149746_1_, int p_149746_2_, int p_149746_3_, int p_149746_4_, Entity p_149746_5_, float p_149746_6_)
- {
- if (!p_149746_1_.isRemote && p_149746_1_.rand.nextFloat() < p_149746_6_ - 0.5F)
- {
- if (!(p_149746_5_ instanceof EntityPlayer) && !p_149746_1_.getGameRules().getGameRuleBooleanValue("mobGriefing"))
- {
- return;
- }
- p_149746_1_.setBlock(p_149746_2_, p_149746_3_, p_149746_4_, Blocks.dirt);
- }
- }
- @Override
- public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable)
- {
- Block plant = plantable.getPlant(world, x, y + 1, z);
- if (plantable instanceof BlockARCrop && ((BlockARCrop)plantable).canPlaceBlockOn(this))
- {
- return true;
- }
- return false;
- }
- private boolean func_149822_e(World p_149822_1_, int p_149822_2_, int p_149822_3_, int p_149822_4_)
- {
- byte b0 = 0;
- for (int l = p_149822_2_ - b0; l <= p_149822_2_ + b0; ++l)
- {
- for (int i1 = p_149822_4_ - b0; i1 <= p_149822_4_ + b0; ++i1)
- {
- Block block = p_149822_1_.getBlock(l, p_149822_3_ + 1, i1);
- if (block instanceof IPlantable && canSustainPlant(p_149822_1_, p_149822_2_, p_149822_3_, p_149822_4_, ForgeDirection.UP, (IPlantable)block))
- {
- return true;
- }
- }
- }
- return false;
- }
- private boolean func_149821_m(World p_149821_1_, int p_149821_2_, int p_149821_3_, int p_149821_4_)
- {
- for (int l = p_149821_2_ - 4; l <= p_149821_2_ + 4; ++l)
- {
- for (int i1 = p_149821_3_; i1 <= p_149821_3_ + 1; ++i1)
- {
- for (int j1 = p_149821_4_ - 4; j1 <= p_149821_4_ + 4; ++j1)
- {
- if (p_149821_1_.getBlock(l, i1, j1).getMaterial() == Material.water)
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- /**
- * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
- * their own) Args: x, y, z, neighbor Block
- */
- public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
- {
- super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_);
- Material material = p_149695_1_.getBlock(p_149695_2_, p_149695_3_ + 1, p_149695_4_).getMaterial();
- if (material.isSolid())
- {
- p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_, Blocks.dirt);
- }
- }
- public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
- {
- return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_);
- }
- /**
- * Gets an item for the block being called on. Args: world, x, y, z
- */
- @SideOnly(Side.CLIENT)
- public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_)
- {
- return Item.getItemFromBlock(Blocks.dirt);
- }
- @SideOnly(Side.CLIENT)
- public void registerBlockIcons(IIconRegister p_149651_1_)
- {
- this.field_149824_a = p_149651_1_.registerIcon(this.getTextureName() + "_wet");
- this.field_149823_b = p_149651_1_.registerIcon(this.getTextureName() + "_dry");
- }
- @Override
- public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
- {
- return new TileEntitySoil();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement