Paper/patches/server/0814-Trigger-bee_nest_destroyed-trigger-in-the-correct-pl.patch
Bjarne Koll 2873869bb1
Drop manual isEditable copy in CraftSign
Signs no longer have a specific isEdiable state, the entire API in this
regard needs updating/deprecation. The boolean field is completely gone,
replaced by a uuid (which will need a new setEditingPlayer(UUID) method
on the Sign interface), and the current upstream implementation of
setEdiable simply flips the is_waxed state.

This patch is hence not needed as it neither allows editing (which will
be redone in a later patch) nor is required to copy the is_waxed boolean
flag as it lives in the signs compound tag and is covered by applyTo.
2023-06-08 11:35:39 +02:00

55 lines
3.3 KiB
Diff

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
index 34def52e9380a4587c5008f1d133a07e72621f56..0f0cf4fdfcbf8537696f15f98f3fb7e68baeb27c 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -426,12 +426,16 @@ public class ServerPlayerGameMode {
block.destroy(this.level, pos, iblockdata);
}
+ ItemStack mainHandStack = null; // Paper
+ boolean isCorrectTool = false; // Paper
if (this.isCreative()) {
// return true; // CraftBukkit
} else {
ItemStack itemstack = this.player.getMainHandItem();
ItemStack itemstack1 = itemstack.copy();
boolean flag1 = this.player.hasCorrectToolForDrops(iblockdata);
+ mainHandStack = itemstack1; // Paper
+ isCorrectTool = flag1; // Paper
itemstack.mineBlock(this.level, iblockdata, pos, this.player);
if (flag && flag1 && event.isDropItems()) { // CraftBukkit - Check if block should drop items
@@ -452,6 +456,13 @@ public class ServerPlayerGameMode {
if (flag && event != null) {
iblockdata.getBlock().popExperience(this.level, pos, event.getExpToDrop(), this.player); // Paper
}
+ // Paper start - trigger after items are dropped (check impls of block#playerDestroy)
+ 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());
+ }
+ }
+ // Paper end
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
index 26f928ad94aed7f1078a31d8a0af2dc377a48d0f..01c8394c6e6b65f40db04280458d0191c116b845 100644
--- a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
@@ -88,7 +88,7 @@ public class BeehiveBlock extends BaseEntityBlock {
this.angerNearbyBees(world, pos);
}
- CriteriaTriggers.BEE_NEST_DESTROYED.trigger((ServerPlayer) player, state, tool, tileentitybeehive.getOccupantCount());
+ // CriteriaTriggers.BEE_NEST_DESTROYED.trigger((ServerPlayer) player, state, tool, tileentitybeehive.getOccupantCount()); // Paper - moved until after items are dropped
}
}