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 31ad06a commit 7bd747f
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
import net.minecraft.world.InteractionHand;
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;
import net.minecraftforge.network.NetworkHooks;

Expand Down Expand Up @@ -56,6 +59,17 @@ public InteractionResult use(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 7bd747f

Please sign in to comment.