Search in sources :

Example 1 with BlockTallGrass

use of net.minecraft.block.BlockTallGrass in project AgriCraft by AgriCraft.

the class GrassDropHandler method interceptGrassDrop.

@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void interceptGrassDrop(BlockEvent.HarvestDropsEvent event) {
    // Skip silk touch.
    if (event.isSilkTouching()) {
        return;
    }
    // Fetch the blockstate.
    final IBlockState state = event.getState();
    // Skip Air or Error
    if (state == null || state.getBlock() == null) {
        return;
    }
    // Fetch the world random.
    final Random rand = event.getWorld().rand;
    // Add grass drops if grass block.
    if (state.getBlock() instanceof BlockTallGrass) {
        // Wipe other drops, if needed.
        if (AgriCraftConfig.wipeGrassDrops) {
            event.getDrops().clear();
        }
        // Log
        // Commenented out to prevent spam.
        // AgriCore.getLogger("agricraft").debug("Inserting Drops!");
        // Add the drops.
        addGrassDrops(event.getDrops(), rand);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockTallGrass(net.minecraft.block.BlockTallGrass) Random(java.util.Random) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

Random (java.util.Random)1 BlockTallGrass (net.minecraft.block.BlockTallGrass)1 IBlockState (net.minecraft.block.state.IBlockState)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1