Commits
md_5 authored aa7768087a2
1 1 | --- a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java |
2 2 | +++ b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java |
3 - | |
3 + | |
4 4 | import net.minecraft.world.phys.Vec3D; |
5 5 | import org.slf4j.Logger; |
6 6 | |
7 7 | +// CraftBukkit start |
8 8 | +import java.util.Arrays; |
9 9 | +import org.bukkit.craftbukkit.block.CraftBlock; |
10 10 | +import org.bukkit.craftbukkit.event.CraftEventFactory; |
11 + | +import org.bukkit.event.block.BlockBrushEvent; |
11 12 | +// CraftBukkit end |
12 13 | + |
13 14 | public class BrushableBlockEntity extends TileEntity { |
14 15 | |
15 16 | private static final Logger LOGGER = LogUtils.getLogger(); |
16 - | |
17 + | |
18 + | IBlockData iblockdata = this.getBlockState(); |
19 + | IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockProperties.DUSTED, k); |
20 + | |
21 + | - worldserver.setBlock(this.getBlockPos(), iblockdata1, 3); |
22 + | + // CraftBukkit start |
23 + | + BlockBrushEvent event = CraftEventFactory.callBlockBrushEvent(worldserver, this.getBlockPos(), iblockdata1, 3, entityhuman); |
24 + | + if (!event.isCancelled()) { |
25 + | + event.getNewState().update(true); |
26 + | + } |
27 + | + // CraftBukkit end |
28 + | } |
29 + | |
30 + | return false; |
31 + | |
32 + | } |
33 + | |
34 + | private void brushingCompleted(WorldServer worldserver, EntityHuman entityhuman, ItemStack itemstack) { |
35 + | - this.dropContent(worldserver, entityhuman, itemstack); |
36 + | + // this.dropContent(worldserver, entityhuman, itemstack); // CraftBukkit - moved down |
37 + | IBlockData iblockdata = this.getBlockState(); |
38 + | |
39 + | - worldserver.levelEvent(3008, this.getBlockPos(), Block.getId(iblockdata)); |
40 + | + // worldserver.levelEvent(3008, this.getBlockPos(), Block.getId(iblockdata)); // CraftBukkit - moved down |
41 + | Block block = this.getBlockState().getBlock(); |
42 + | Block block1; |
43 + | |
44 + | |
45 + | block1 = Blocks.AIR; |
46 + | } |
47 + | |
48 + | - worldserver.setBlock(this.worldPosition, block1.defaultBlockState(), 3); |
49 + | + // CraftBukkit start |
50 + | + BlockBrushEvent event = CraftEventFactory.callBlockBrushEvent(worldserver, this.worldPosition, block1.defaultBlockState(), 3, entityhuman); |
51 + | + if (!event.isCancelled()) { |
52 + | + this.dropContent(worldserver, entityhuman, itemstack); // CraftBukkit - from above |
53 + | + worldserver.levelEvent(3008, this.getBlockPos(), Block.getId(iblockdata)); // CraftBukkit - from above |
54 + | + |
55 + | + event.getNewState().update(true); |
56 + | + } |
57 + | + // CraftBukkit end |
58 + | } |
59 + | |
60 + | private void dropContent(WorldServer worldserver, EntityHuman entityhuman, ItemStack itemstack) { |
61 + | |
17 62 | EntityItem entityitem = new EntityItem(worldserver, d3, d4, d5, this.item.split(worldserver.random.nextInt(21) + 10)); |
18 63 | |
19 64 | entityitem.setDeltaMovement(Vec3D.ZERO); |
20 65 | - worldserver.addFreshEntity(entityitem); |
21 66 | + // CraftBukkit start |
22 67 | + org.bukkit.block.Block bblock = CraftBlock.at(this.level, this.worldPosition); |
23 68 | + CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), (EntityPlayer) entityhuman, Arrays.asList(entityitem)); |
24 69 | + // CraftBukkit end |
25 70 | this.item = ItemStack.EMPTY; |
26 71 | } |
27 72 |