73 lines
3.2 KiB
Diff
73 lines
3.2 KiB
Diff
--- a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
|
|
+++ b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
|
|
@@ -31,6 +31,13 @@
|
|
import net.minecraft.world.phys.Vec3D;
|
|
import org.slf4j.Logger;
|
|
|
|
+// CraftBukkit start
|
|
+import java.util.Arrays;
|
|
+import org.bukkit.craftbukkit.block.CraftBlock;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+import org.bukkit.event.block.BlockBrushEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class BrushableBlockEntity extends TileEntity {
|
|
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
|
@@ -80,7 +87,12 @@
|
|
IBlockData iblockdata = this.getBlockState();
|
|
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockProperties.DUSTED, k);
|
|
|
|
- worldserver.setBlock(this.getBlockPos(), iblockdata1, 3);
|
|
+ // CraftBukkit start
|
|
+ BlockBrushEvent event = CraftEventFactory.callBlockBrushEvent(worldserver, this.getBlockPos(), iblockdata1, 3, entityhuman);
|
|
+ if (!event.isCancelled()) {
|
|
+ event.getNewState().update(true);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
return false;
|
|
@@ -121,10 +133,10 @@
|
|
}
|
|
|
|
private void brushingCompleted(WorldServer worldserver, EntityHuman entityhuman, ItemStack itemstack) {
|
|
- this.dropContent(worldserver, entityhuman, itemstack);
|
|
+ // this.dropContent(worldserver, entityhuman, itemstack); // CraftBukkit - moved down
|
|
IBlockData iblockdata = this.getBlockState();
|
|
|
|
- worldserver.levelEvent(3008, this.getBlockPos(), Block.getId(iblockdata));
|
|
+ // worldserver.levelEvent(3008, this.getBlockPos(), Block.getId(iblockdata)); // CraftBukkit - moved down
|
|
Block block = this.getBlockState().getBlock();
|
|
Block block1;
|
|
|
|
@@ -134,7 +146,15 @@
|
|
block1 = Blocks.AIR;
|
|
}
|
|
|
|
- worldserver.setBlock(this.worldPosition, block1.defaultBlockState(), 3);
|
|
+ // CraftBukkit start
|
|
+ BlockBrushEvent event = CraftEventFactory.callBlockBrushEvent(worldserver, this.worldPosition, block1.defaultBlockState(), 3, entityhuman);
|
|
+ if (!event.isCancelled()) {
|
|
+ this.dropContent(worldserver, entityhuman, itemstack); // CraftBukkit - from above
|
|
+ worldserver.levelEvent(3008, this.getBlockPos(), Block.getId(iblockdata)); // CraftBukkit - from above
|
|
+
|
|
+ event.getNewState().update(true);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
private void dropContent(WorldServer worldserver, EntityHuman entityhuman, ItemStack itemstack) {
|
|
@@ -151,7 +171,10 @@
|
|
EntityItem entityitem = new EntityItem(worldserver, d3, d4, d5, this.item.split(worldserver.random.nextInt(21) + 10));
|
|
|
|
entityitem.setDeltaMovement(Vec3D.ZERO);
|
|
- worldserver.addFreshEntity(entityitem);
|
|
+ // CraftBukkit start
|
|
+ org.bukkit.block.Block bblock = CraftBlock.at(this.level, this.worldPosition);
|
|
+ CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), (EntityPlayer) entityhuman, Arrays.asList(entityitem));
|
|
+ // CraftBukkit end
|
|
this.item = ItemStack.EMPTY;
|
|
}
|
|
|