public void OnConsume(Player player) { PlayerEatFoodEvent playerEatFoodEvent = new PlayerEatFoodEvent(player, this); PlayerEvents.OnPlayerEatFood(playerEatFoodEvent); if (playerEatFoodEvent.IsCancel) { player.Inventory.SendMainHand(player); return; } player.AddHunger(this.FoodRestore); player.AddSaturation(this.SaturationRestore); Effect[] effects = this.AdditionalEffects; for (int i = 0; i < effects.Length; ++i) { player.AddEffect(effects[i]); } this.Count--; if (this.Count < 1) { player.Inventory.SetItem(player.Inventory.MainHandSlot, Item.Get(BlockFactory.AIR), false); } }
public static void OnPlayerEatFood(PlayerEatFoodEvent args) { PlayerEatFood?.Invoke(args); }