mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2024-11-22 10:06:16 +00:00
84 lines
4.3 KiB
Diff
84 lines
4.3 KiB
Diff
--- a/net/minecraft/world/level/block/SculkSensorBlock.java
|
|
+++ b/net/minecraft/world/level/block/SculkSensorBlock.java
|
|
@@ -44,6 +44,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<SculkSensorBlock> CODEC = simpleCodec(SculkSensorBlock::new);
|
|
@@ -104,6 +109,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) {
|
|
@@ -207,6 +224,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);
|
|
@@ -218,6 +244,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);
|
|
@@ -298,9 +333,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
|
|
}
|
|
}
|