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);
}
}
}
}
Aggregations