Skip to content

Commit

Permalink
Fix #264
Browse files Browse the repository at this point in the history
  • Loading branch information
Edivad99 committed Nov 12, 2024
1 parent 590611d commit 48ca51a
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.BaseRailBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.redstone.Redstone;
import net.minecraft.world.phys.BlockHitResult;

public abstract class ManipulatorBlock<T extends ManipulatorBlockEntity> extends BaseEntityBlock {
Expand Down Expand Up @@ -54,6 +57,17 @@ protected InteractionResult useWithoutItem(BlockState blockState, Level level,

public abstract Direction getFacing(BlockState blockState);

@Override
public int getSignal(BlockState blockState, BlockGetter level, BlockPos blockPos,
Direction direction) {
boolean emit = false;
if (isPowered(blockState)) {
var neighborBlockState = level.getBlockState(blockPos.relative(direction.getOpposite()));
emit = BaseRailBlock.isRail(neighborBlockState);
}
return emit ? Redstone.SIGNAL_MAX : Redstone.SIGNAL_NONE;
}

@SuppressWarnings("deprecation")
@Override
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState,
Expand Down

0 comments on commit 48ca51a

Please sign in to comment.