craftbukkit/nms-patches/net/minecraft/world/item/ItemBoneMeal.patch

33 lines
1.7 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/item/ItemBoneMeal.java
+++ b/net/minecraft/world/item/ItemBoneMeal.java
2024-04-24 01:15:00 +10:00
@@ -35,13 +35,19 @@
2020-08-27 11:27:13 +10:00
@Override
2021-11-22 09:00:00 +11:00
public EnumInteractionResult useOn(ItemActionContext itemactioncontext) {
2020-08-27 11:27:13 +10:00
+ // CraftBukkit start - extract bonemeal application logic to separate, static method
+ return applyBonemeal(itemactioncontext);
+ }
+
+ public static EnumInteractionResult applyBonemeal(ItemActionContext itemactioncontext) {
+ // CraftBukkit end
2021-11-22 09:00:00 +11:00
World world = itemactioncontext.getLevel();
BlockPosition blockposition = itemactioncontext.getClickedPos();
BlockPosition blockposition1 = blockposition.relative(itemactioncontext.getClickedFace());
if (growCrop(itemactioncontext.getItemInHand(), world, blockposition)) {
if (!world.isClientSide) {
- itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH);
+ if (itemactioncontext.getPlayer() != null) itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518
2024-04-24 01:15:00 +10:00
world.levelEvent(1505, blockposition, 15);
}
2024-04-24 01:15:00 +10:00
@@ -52,7 +58,7 @@
if (flag && growWaterPlant(itemactioncontext.getItemInHand(), world, blockposition1, itemactioncontext.getClickedFace())) {
if (!world.isClientSide) {
- itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH);
+ if (itemactioncontext.getPlayer() != null) itemactioncontext.getPlayer().gameEvent(GameEvent.ITEM_INTERACT_FINISH); // CraftBukkit - SPIGOT-7518
2024-04-24 01:15:00 +10:00
world.levelEvent(1505, blockposition1, 15);
}