1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-26 07:03:22 +00:00

Make redstone updates identical to how MC does it

Also fixes rather embarassing bug with redstone not updating.
This commit is contained in:
SquidDev 2019-04-06 22:42:03 +01:00
parent 0e191e42a0
commit 765c31315a

View File

@ -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() );
}
}