食料を即座に食べられるようにする

難読化地獄なのでコメントで何してるか書いてます 1.19.4で動作確認しています それ以外は自分でバージョン部分(v1_19_R3)書き換えてください https://www.spigotmc.org/wiki/spigot-nms-and-minecraft-versions-1-16/
import:
org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack

on rightclick with food:
# プレイヤーの満腹度を取得
set {_playernutrition} to player.getFoodLevel()
if {_playernutrition} is not 20:
cancel event

# bukkitのCraftItemStackをminecraftのItemStackに
set {_item} to CraftItemStack.asNMSCopy(event-item)

# ItemStackをgetItem()でItemに
set {_item} to {_item}.c()

# ItemをgetFoodProperties()でFoodProperties(FoodInfo)に
set {_item} to {_item}.v()

# FoodInfoでgetNutrition()をして満腹度回復量を得る
set {_nutrition} to {_item}.a()

# FoodInfoでgetSaturationModifier()をして隠し満腹度回復量を得る
set {_saturation} to {_item}.b()

# プレイヤーの隠し満腹度を取得
set {_playersaturation} to player.getSaturation()

set {_n} to {_nutrition} + {_playernutrition}
set {_s} to {_saturation} + {_playersaturation}

set {_n} to 20 if {_n} > 20
set {_s} to 20 if {_s} > 20

remove 1 of event-item from player
play sound "entity.generic.eat" at location of player to all players

# プレイヤーの満腹度を設定
player.setFoodLevel({_n})
player.setSaturation({_s})
import:
org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack

on rightclick with food:
# プレイヤーの満腹度を取得
set {_playernutrition} to player.getFoodLevel()
if {_playernutrition} is not 20:
cancel event

# bukkitのCraftItemStackをminecraftのItemStackに
set {_item} to CraftItemStack.asNMSCopy(event-item)

# ItemStackをgetItem()でItemに
set {_item} to {_item}.c()

# ItemをgetFoodProperties()でFoodProperties(FoodInfo)に
set {_item} to {_item}.v()

# FoodInfoでgetNutrition()をして満腹度回復量を得る
set {_nutrition} to {_item}.a()

# FoodInfoでgetSaturationModifier()をして隠し満腹度回復量を得る
set {_saturation} to {_item}.b()

# プレイヤーの隠し満腹度を取得
set {_playersaturation} to player.getSaturation()

set {_n} to {_nutrition} + {_playernutrition}
set {_s} to {_saturation} + {_playersaturation}

set {_n} to 20 if {_n} > 20
set {_s} to 20 if {_s} > 20

remove 1 of event-item from player
play sound "entity.generic.eat" at location of player to all players

# プレイヤーの満腹度を設定
player.setFoodLevel({_n})
player.setSaturation({_s})
skriptとskript-reflectで動きます
1 Reply
あお🦀
あお🦀OP6mo ago
tanoKunさんに感謝
Want results from more Discord servers?
Add your server