mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-20 23:46:57 +01:00
Clean up callBlockDamageEvent
By: md_5 <git@md-5.net>
This commit is contained in:
parent
e664c2bf5f
commit
d5e124a72d
2 changed files with 5 additions and 8 deletions
|
@ -122,7 +122,7 @@
|
|||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.getInventory().getSelected(), f >= 1.0f);
|
||||
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition, this.player.getInventory().getSelected(), f >= 1.0f);
|
||||
+
|
||||
+ if (blockEvent.isCancelled()) {
|
||||
+ // Let the client know the block still exists
|
||||
|
|
|
@ -560,17 +560,14 @@ public class CraftEventFactory {
|
|||
/**
|
||||
* BlockDamageEvent
|
||||
*/
|
||||
public static BlockDamageEvent callBlockDamageEvent(EntityHuman who, int x, int y, int z, ItemStack itemstack, boolean instaBreak) {
|
||||
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
|
||||
public static BlockDamageEvent callBlockDamageEvent(EntityPlayer who, BlockPosition pos, ItemStack itemstack, boolean instaBreak) {
|
||||
Player player = who.getBukkitEntity();
|
||||
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
|
||||
|
||||
CraftWorld craftWorld = (CraftWorld) player.getWorld();
|
||||
CraftServer craftServer = (CraftServer) player.getServer();
|
||||
|
||||
Block blockClicked = craftWorld.getBlockAt(x, y, z);
|
||||
Block blockClicked = CraftBlock.at(who.getLevel(), pos);
|
||||
|
||||
BlockDamageEvent event = new BlockDamageEvent(player, blockClicked, itemInHand, instaBreak);
|
||||
craftServer.getPluginManager().callEvent(event);
|
||||
player.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
return event;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue