--- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java @@ -43,6 +43,11 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShapeCollision; +// CraftBukkit start +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.event.block.BlockRedstoneEvent; +// CraftBukkit end + public class SculkSensorBlock extends BlockTileEntity implements IBlockWaterlogged { public static final MapCodec CODEC = simpleCodec(SculkSensorBlock::new); @@ -103,6 +108,18 @@ @Override public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { if (!world.isClientSide() && canActivate(iblockdata) && entity.getType() != EntityTypes.WARDEN) { + // CraftBukkit start + org.bukkit.event.Cancellable cancellable; + if (entity instanceof EntityHuman) { + cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null); + } else { + cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getCraftServer().getPluginManager().callEvent((org.bukkit.event.entity.EntityInteractEvent) cancellable); + } + if (cancellable.isCancelled()) { + return; + } + // CraftBukkit end TileEntity tileentity = world.getBlockEntity(blockposition); if (tileentity instanceof SculkSensorBlockEntity) { @@ -206,6 +223,15 @@ } public static void deactivate(World world, BlockPosition blockposition, IBlockData iblockdata) { + // CraftBukkit start + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), iblockdata.getValue(SculkSensorBlock.POWER), 0); + world.getCraftServer().getPluginManager().callEvent(eventRedstone); + + if (eventRedstone.getNewCurrent() > 0) { + world.setBlock(blockposition, iblockdata.setValue(SculkSensorBlock.POWER, eventRedstone.getNewCurrent()), 3); + return; + } + // CraftBukkit end world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.COOLDOWN)).setValue(SculkSensorBlock.POWER, 0), 3); world.scheduleTick(blockposition, iblockdata.getBlock(), 10); updateNeighbours(world, blockposition, iblockdata); @@ -217,6 +243,15 @@ } public void activate(@Nullable Entity entity, World world, BlockPosition blockposition, IBlockData iblockdata, int i, int j) { + // CraftBukkit start + BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(world, blockposition), iblockdata.getValue(SculkSensorBlock.POWER), i); + world.getCraftServer().getPluginManager().callEvent(eventRedstone); + + if (eventRedstone.getNewCurrent() <= 0) { + return; + } + i = eventRedstone.getNewCurrent(); + // CraftBukkit end world.setBlock(blockposition, (IBlockData) ((IBlockData) iblockdata.setValue(SculkSensorBlock.PHASE, SculkSensorPhase.ACTIVE)).setValue(SculkSensorBlock.POWER, i), 3); world.scheduleTick(blockposition, iblockdata.getBlock(), this.getActiveTicks()); updateNeighbours(world, blockposition, iblockdata); @@ -297,9 +332,16 @@ @Override protected void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag); + // CraftBukkit start - Delegate to getExpDrop + } + + @Override + public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) { if (flag) { - this.tryDropExperience(worldserver, blockposition, itemstack, ConstantInt.of(5)); + return this.tryDropExperience(worldserver, blockposition, itemstack, ConstantInt.of(5)); } + return 0; + // CraftBukkit end } }