mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-13 11:40:29 +00:00
Replace RedstoneUtil.getRedstoneOutput with World's implementation
This has just become increasingly out-of-date and inaccurate, meaning there's no obvious reason to continue to use this over World's version. Fixes #80
This commit is contained in:
parent
741ee447ca
commit
8b86a954ee
@ -1,14 +1,12 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2017. Do not distribute without permission.
|
||||
* Copyright Daniel Ratcliffe, 2011-2018. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRedstoneWire;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@ -19,53 +17,13 @@ public class RedstoneUtil
|
||||
{
|
||||
public static int getRedstoneOutput( World world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
int power = 0;
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
if( block != Blocks.AIR )
|
||||
{
|
||||
if( block == Blocks.REDSTONE_WIRE )
|
||||
{
|
||||
if( side != EnumFacing.UP )
|
||||
{
|
||||
power = state.getValue( BlockRedstoneWire.POWER );
|
||||
}
|
||||
else
|
||||
{
|
||||
power = 0;
|
||||
}
|
||||
}
|
||||
else if( state.canProvidePower( ) )
|
||||
{
|
||||
power = state.getWeakPower( world, pos, side.getOpposite() );
|
||||
}
|
||||
if( block.isNormalCube( state, world, pos ) )
|
||||
{
|
||||
for( EnumFacing testSide : EnumFacing.VALUES )
|
||||
{
|
||||
if( testSide != side )
|
||||
{
|
||||
BlockPos testPos = pos.offset( testSide );
|
||||
IBlockState neighbour = world.getBlockState( testPos );
|
||||
if( neighbour.canProvidePower( ) )
|
||||
{
|
||||
power = Math.max( power, neighbour.getStrongPower( world, testPos, testSide.getOpposite() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return power;
|
||||
return world.getRedstonePower( pos, side );
|
||||
}
|
||||
|
||||
public static int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
int signal = ComputerCraft.getBundledRedstoneOutput( world, pos, side );
|
||||
if( signal >= 0 )
|
||||
{
|
||||
return signal;
|
||||
}
|
||||
return 0;
|
||||
return signal >= 0 ? signal : 0;
|
||||
}
|
||||
|
||||
public static void propagateRedstoneOutput( World world, BlockPos pos, EnumFacing side )
|
||||
|
Loading…
Reference in New Issue
Block a user