2022-04-23 03:17:14 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 2 Feb 2022 13:50:06 -0800
Subject: [PATCH] Trigger bee_nest_destroyed trigger in the correct place
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
2024-05-29 22:58:57 +02:00
index c55d944a70300bf77dbde918c91815cabe68496d..ac2bd55deeef8e14b8fa0db1f2d10e36d045f0e4 100644
2022-04-23 03:17:14 +02:00
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
2024-04-24 22:05:42 +02:00
@@ -424,12 +424,16 @@ public class ServerPlayerGameMode {
2023-12-06 17:00:26 +01:00
block.destroy(this.level, pos, iblockdata1);
2022-04-23 03:17:14 +02:00
}
2024-01-18 18:52:00 +01:00
+ ItemStack mainHandStack = null; // Paper - Trigger bee_nest_destroyed trigger in the correct place
+ boolean isCorrectTool = false; // Paper - Trigger bee_nest_destroyed trigger in the correct place
2022-04-23 03:17:14 +02:00
if (this.isCreative()) {
// return true; // CraftBukkit
} else {
ItemStack itemstack = this.player.getMainHandItem();
ItemStack itemstack1 = itemstack.copy();
2023-12-06 17:00:26 +01:00
boolean flag1 = this.player.hasCorrectToolForDrops(iblockdata1);
2024-01-18 18:52:00 +01:00
+ mainHandStack = itemstack1; // Paper - Trigger bee_nest_destroyed trigger in the correct place
+ isCorrectTool = flag1; // Paper - Trigger bee_nest_destroyed trigger in the correct place
2022-04-23 03:17:14 +02:00
2023-12-06 17:00:26 +01:00
itemstack.mineBlock(this.level, iblockdata1, pos, this.player);
2022-04-23 03:17:14 +02:00
if (flag && flag1 && event.isDropItems()) { // CraftBukkit - Check if block should drop items
2024-04-24 22:05:42 +02:00
@@ -450,6 +454,13 @@ public class ServerPlayerGameMode {
2022-04-23 03:17:14 +02:00
if (flag && event != null) {
iblockdata.getBlock().popExperience(this.level, pos, event.getExpToDrop(), this.player); // Paper
}
2024-01-18 18:52:00 +01:00
+ // Paper start - Trigger bee_nest_destroyed trigger in the correct place (check impls of block#playerDestroy)
2022-04-23 03:17:14 +02:00
+ if (mainHandStack != null) {
+ if (flag && isCorrectTool && event.isDropItems() && block instanceof net.minecraft.world.level.block.BeehiveBlock && tileentity instanceof net.minecraft.world.level.block.entity.BeehiveBlockEntity beehiveBlockEntity) { // simulates the guard on block#playerDestroy above
+ CriteriaTriggers.BEE_NEST_DESTROYED.trigger(player, iblockdata, mainHandStack, beehiveBlockEntity.getOccupantCount());
+ }
+ }
2024-01-18 18:52:00 +01:00
+ // Paper end - Trigger bee_nest_destroyed trigger in the correct place
2022-04-23 03:17:14 +02:00
return true;
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
2024-04-25 21:16:00 +02:00
index ef804067ee05870e9331237b44ca1ffeb8df99c7..21a7f9414e27c73b58fd75fbe68cf889f52a5d01 100644
2022-04-23 03:17:14 +02:00
--- a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
2023-12-06 17:00:26 +01:00
@@ -95,7 +95,7 @@ public class BeehiveBlock extends BaseEntityBlock {
2022-04-23 03:17:14 +02:00
this.angerNearbyBees(world, pos);
}
2023-03-14 22:10:53 +01:00
- CriteriaTriggers.BEE_NEST_DESTROYED.trigger((ServerPlayer) player, state, tool, tileentitybeehive.getOccupantCount());
2024-01-18 18:52:00 +01:00
+ // CriteriaTriggers.BEE_NEST_DESTROYED.trigger((ServerPlayer) player, state, tool, tileentitybeehive.getOccupantCount()); // Paper - Trigger bee_nest_destroyed trigger in the correct place; moved until after items are dropped
2022-04-23 03:17:14 +02:00
}
}