From 765c31315a460f70913d8e78a00de5094ad46b4c Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 6 Apr 2019 22:42:03 +0100 Subject: [PATCH] Make redstone updates identical to how MC does it Also fixes rather embarassing bug with redstone not updating. --- .../shared/util/RedstoneUtil.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/util/RedstoneUtil.java b/src/main/java/dan200/computercraft/shared/util/RedstoneUtil.java index 85e5c6717..7f30c8db1 100644 --- a/src/main/java/dan200/computercraft/shared/util/RedstoneUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/RedstoneUtil.java @@ -11,6 +11,9 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.event.ForgeEventFactory; + +import java.util.EnumSet; public final class RedstoneUtil { @@ -30,17 +33,12 @@ public static int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacin public static void propagateRedstoneOutput( World world, BlockPos pos, EnumFacing side ) { - // Propagate ordinary output + // Propagate ordinary output. See BlockRedstoneDiode.notifyNeighbors IBlockState block = world.getBlockState( pos ); + if( ForgeEventFactory.onNeighborNotify( world, pos, block, EnumSet.of( side ), false ).isCanceled() ) return; + BlockPos neighbourPos = pos.offset( side ); - IBlockState neighbour = world.getBlockState( neighbourPos ); - if( neighbour.getBlock().isAir( neighbour, world, neighbourPos ) ) - { - world.neighborChanged( neighbourPos, block.getBlock(), pos ); - if( neighbour.getBlock().isNormalCube( neighbour, world, neighbourPos ) ) - { - world.notifyNeighborsOfStateExcept( neighbourPos, block.getBlock(), side.getOpposite() ); - } - } + world.neighborChanged( neighbourPos, block.getBlock(), pos ); + world.notifyNeighborsOfStateExcept( neighbourPos, block.getBlock(), side.getOpposite() ); } }