Search in sources :

Example 1 with CropBlock

use of com.almuradev.content.type.block.type.crop.CropBlock in project Almura by AlmuraDev.

the class ItemReturnHelper method onHarvestBlock.

// Sunflower Destroy Action Modifier & charging the player food/drink for harvesting custom crops.
@SubscribeEvent
public void onHarvestBlock(BlockEvent.HarvestDropsEvent event) {
    Block block = event.getState().getBlock();
    if (block instanceof CropBlock) {
        EntityPlayer player = event.getHarvester();
        if (player != null)
            // This is how we make players use more food/drink...
            player.addExhaustion(0.01F);
    }
    if (block instanceof BlockDoublePlant) {
        if (block.getMetaFromState(event.getState()) == 0) {
            // 0 = Sunflower Type.
            final ItemStack drop = GameRegistry.makeItemStack("almura:food/food/sunflowerseed", 0, 16, null);
            if (drop != ItemStack.EMPTY) {
                // Destroy the sunflower return.
                event.getDrops().clear();
                // Return Sunflower seeds, yeh!
                event.getDrops().add(drop);
            }
        }
    }
}
Also used : CropBlock(com.almuradev.content.type.block.type.crop.CropBlock) Block(net.minecraft.block.Block) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockDoublePlant(net.minecraft.block.BlockDoublePlant) CropBlock(com.almuradev.content.type.block.type.crop.CropBlock) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

CropBlock (com.almuradev.content.type.block.type.crop.CropBlock)1 Block (net.minecraft.block.Block)1 BlockDoublePlant (net.minecraft.block.BlockDoublePlant)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1