mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
41 lines
2.4 KiB
Diff
41 lines
2.4 KiB
Diff
--- a/net/minecraft/server/ItemBlock.java
|
|
+++ b/net/minecraft/server/ItemBlock.java
|
|
@@ -3,6 +3,11 @@
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
import javax.annotation.Nullable;
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.block.CraftBlock;
|
|
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
|
+import org.bukkit.event.block.BlockCanBuildEvent;
|
|
+// CraftBukkit end
|
|
|
|
public class ItemBlock extends Item {
|
|
|
|
@@ -55,7 +60,7 @@
|
|
|
|
SoundEffectType soundeffecttype = iblockdata1.r();
|
|
|
|
- world.a(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F);
|
|
+ // world.a(entityhuman, blockposition, this.a(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.a() + 1.0F) / 2.0F, soundeffecttype.b() * 0.8F);
|
|
itemstack.subtract(1);
|
|
return EnumInteractionResult.SUCCESS;
|
|
}
|
|
@@ -120,8 +125,15 @@
|
|
protected boolean b(BlockActionContext blockactioncontext, IBlockData iblockdata) {
|
|
EntityHuman entityhuman = blockactioncontext.getEntity();
|
|
VoxelShapeCollision voxelshapecollision = entityhuman == null ? VoxelShapeCollision.a() : VoxelShapeCollision.a((Entity) entityhuman);
|
|
+ // CraftBukkit start - store default return
|
|
+ boolean defaultReturn = (!this.d() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision);
|
|
+ org.bukkit.entity.Player player = (blockactioncontext.getEntity() instanceof EntityPlayer) ? (org.bukkit.entity.Player) blockactioncontext.getEntity().getBukkitEntity() : null;
|
|
|
|
- return (!this.d() || iblockdata.canPlace(blockactioncontext.getWorld(), blockactioncontext.getClickPosition())) && blockactioncontext.getWorld().a(iblockdata, blockactioncontext.getClickPosition(), voxelshapecollision);
|
|
+ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(blockactioncontext.getWorld(), blockactioncontext.getClickPosition()), player, CraftBlockData.fromData(iblockdata), defaultReturn);
|
|
+ blockactioncontext.getWorld().getServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ return event.isBuildable();
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
protected boolean d() {
|