SHARE
TWEET

Untitled

a guest Sep 17th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*============================FORGE START=====================================*/
  2.     @Override
  3.     public void getDrops(net.minecraft.util.NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
  4.     {
  5.         super.getDrops(drops, world, pos, state, fortune);
  6.         TileEntityFlowerPot te = world.getTileEntity(pos) instanceof TileEntityFlowerPot ? (TileEntityFlowerPot)world.getTileEntity(pos) : null;
  7.         if (te != null && te.getFlowerPotItem() != null)
  8.             drops.add(new ItemStack(te.getFlowerPotItem(), 1, te.getFlowerPotData()));
  9.     }
  10.     @Override
  11.     public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest)
  12.     {
  13.         if (willHarvest) return true; //If it will harvest, delay deletion of the block until after getDrops
  14.         return super.removedByPlayer(state, world, pos, player, willHarvest);
  15.     }
  16.     /**
  17.      * Spawns the block's drops in the world. By the time this is called the Block has possibly been set to air via
  18.      * Block.removedByPlayer
  19.      */
  20.     @Override
  21.     public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack tool)
  22.     {
  23.         super.harvestBlock(world, player, pos, state, te, tool);
  24.         world.setBlockToAir(pos);
  25.     }
  26.     /*===========================FORGE END==========================================*/
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top