Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
fix: looty:food not handling properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Nov 30, 2023
1 parent 0bf894b commit 3b03b4b
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ import org.bukkit.inventory.EquipmentSlot
import kotlin.random.Random

class FoodConsumptionListener : Listener {

@EventHandler
fun PlayerItemConsumeEvent.onConsumeFood() {
val gearyInventory = player.inventory.toGeary() ?: return

val entity = if (hand == EquipmentSlot.HAND)
gearyInventory.itemInMainHand
else gearyInventory.itemInOffhand ?: return

val entity = if (hand == EquipmentSlot.HAND) gearyInventory.itemInMainHand else gearyInventory.itemInOffhand ?: return
val gearyFood = entity?.get<Food>() ?: return

val replacement = gearyFood.replacement?.toItemStack()
isCancelled = true // Cancel vanilla behaviour

if (player.gameMode != GameMode.CREATIVE) {
if (replacement != null) {
Expand Down

0 comments on commit 3b03b4b

Please sign in to comment.