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

Make redstone behaviour consistent with repeaters

This uses the same behaviour that repeaters and comparators do for
determining their input, meaning that redstone directly connected to the
computer is read (as you would expect).

It's worth noting that this is a shift from previous behaviour.
Therefore, it runs the (small) risk of breaking existing builds.
However, I believe it is more consistent with the expected behaviour.
This commit is contained in:
SquidDev 2019-04-22 11:52:01 +01:00
parent 6898f932a0
commit 7071cc972b

View File

@ -22,7 +22,10 @@
import dan200.computercraft.shared.util.RedstoneUtil;
import joptsimple.internal.Strings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneWire;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -34,6 +37,7 @@
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.IWorldNameable;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -266,7 +270,7 @@ private void updateSideInput( ServerComputer computer, EnumFacing dir, BlockPos
EnumFacing offsetSide = dir.getOpposite();
ComputerSide localDir = remapLocalSide( DirectionUtil.toLocal( this, dir ) );
computer.setRedstoneInput( localDir, getWorld().getRedstonePower( offset, dir ) );
computer.setRedstoneInput( localDir, getRedstoneInput( world, offset, dir ) );
computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( getWorld(), offset, offsetSide ) );
if( !isPeripheralBlockedOnSide( localDir ) )
@ -275,6 +279,26 @@ private void updateSideInput( ServerComputer computer, EnumFacing dir, BlockPos
}
}
/**
* Gets the redstone input for an adjacent block
*
* @param world The world we exist in
* @param pos The position of the neighbour
* @param side The side we are reading from
* @return The effective redstone power
* @see net.minecraft.block.BlockRedstoneDiode#calculateInputStrength(World, BlockPos, IBlockState)
*/
protected static int getRedstoneInput( World world, BlockPos pos, EnumFacing side )
{
int power = world.getRedstonePower( pos, side );
if( power >= 15 ) return power;
IBlockState neighbour = world.getBlockState( pos );
return neighbour.getBlock() == Blocks.REDSTONE_WIRE
? Math.max( power, neighbour.getValue( BlockRedstoneWire.POWER ) )
: power;
}
public void updateInput()
{
if( getWorld() == null || getWorld().isRemote ) return;