Skip to content

Commit

Permalink
High Speed Repeater
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiYueCommentary committed Sep 18, 2024
1 parent 5354c60 commit 6b11d51
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion fabric/src/main/java/ziyue/tjmetro/mod/BlockList.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public interface BlockList
BlockRegistryObject PSD_GLASS_END_TIANJIN_BLOCK = Registry.registerBlock("psd_glass_end_tianjin", () -> new Block(new BlockPSDGlassEndTianjin()));
BlockRegistryObject PSD_TOP_TIANJIN = Registry.registerBlock("psd_top_tianjin", () -> new Block(new BlockPSDTopTianjin()));
BlockRegistryObject METAL_DETECTION_DOOR = Registry.registerBlockWithBlockItem("metal_detection_door", () -> new Block(new BlockMetalDetectionDoor()), CreativeModeTabs.TIANJIN_METRO);
// BlockRegistryObject HIGH_SPEED_REPEATER = Registry.registerBlockWithBlockItem("high_speed_repeater", () -> new Block(new BlockHighSpeedRepeater()), CreativeModeTabs.TIANJIN_METRO);
BlockRegistryObject HIGH_SPEED_REPEATER = Registry.registerBlockWithBlockItem("high_speed_repeater", () -> new Block(new BlockHighSpeedRepeater()), CreativeModeTabs.TIANJIN_METRO);
BlockRegistryObject STATION_NAME_WALL_LEGACY = Registry.registerBlockWithBlockItem("station_name_wall_legacy", () -> new Block(new BlockStationNameWallLegacy()), CreativeModeTabs.TIANJIN_METRO);
BlockRegistryObject STATION_NAME_PLATE = Registry.registerBlockWithBlockItem("station_name_plate", () -> new Block(new BlockStationNamePlate()), CreativeModeTabs.TIANJIN_METRO);
BlockRegistryObject STATION_NAME_PLATE_MIDDLE = Registry.registerBlock("station_name_plate_middle", () -> new Block(new BlockStationNamePlate()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static void init() {
RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_DOOR_TIANJIN_BMT_BLOCK);
RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_GLASS_TIANJIN_BMT_BLOCK);
RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_GLASS_END_TIANJIN_BMT_BLOCK);
RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.HIGH_SPEED_REPEATER);

RegistryClient.registerBlockEntityRenderer(BlockEntityTypes.STATION_NAME_SIGN_1, RenderStationNameSign::new);
RegistryClient.registerBlockEntityRenderer(BlockEntityTypes.STATION_NAME_SIGN_2, RenderStationNameSign::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
/**
* @author ZiYueCommentary
* @since 1.0.0-beta-1
* @deprecated
*/

// Screw this.
@Deprecated
public class BlockHighSpeedRepeater extends BlockExtension implements DirectionHelper
{
public static final BooleanProperty LOCKED = BooleanProperty.of("locked");
Expand All @@ -40,7 +37,7 @@ public VoxelShape getOutlineShape2(BlockState state, BlockView world, BlockPos p

@Override
public int getStrongRedstonePower2(BlockState state, BlockView world, BlockPos pos, Direction direction) {
return IBlock.getStatePropertySafe(state, POWERED) ? 15 : 0;
return direction == IBlock.getStatePropertySafe(state, FACING) && IBlock.getStatePropertySafe(state, POWERED) ? 15 : 0;
}

@Override
Expand All @@ -50,11 +47,15 @@ public int getWeakRedstonePower2(BlockState state, BlockView world, BlockPos pos

@Override
public void neighborUpdate2(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
if (this.isLocked(world, pos, state)) return;
Direction direction = IBlock.getStatePropertySafe(state, FACING);
BlockPos blockPos1 = pos.offset(direction);
boolean powered = world.getBlockState(blockPos1).getStrongRedstonePower(new BlockView(world.data), blockPos1, direction) > 0;
world.setBlockState(pos, state.with(new Property<>(POWERED.data), powered));
if (IBlock.getStatePropertySafe(state, LOCKED)) {
world.setBlockState(pos, state.with(new Property<>(LOCKED.data), this.isLocked(world, pos, state)));
return;
}
final Direction direction = IBlock.getStatePropertySafe(state, FACING);
final BlockPos blockPos1 = pos.offset(direction);
final boolean powered = world.getBlockState(blockPos1).getStrongRedstonePower(new BlockView(world.data), blockPos1, direction) > 0;
final boolean isLocked = this.isLocked(world, pos, state);
world.setBlockState(pos, state.with(new Property<>(POWERED.data), powered).with(new Property<>(LOCKED.data), isLocked));
}

protected int getInputLevel(World world, BlockPos pos, Direction dir) {
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/java/ziyue/tjmetro/mod/client/Filters.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface Filters

static void init() {
FilterBuilder.addItems(Filters.TIANJIN_MISCELLANEOUS, WRENCH);
FilterBuilder.addBlocks(Filters.TIANJIN_MISCELLANEOUS, PLAYER_DETECTOR);
FilterBuilder.addBlocks(Filters.TIANJIN_MISCELLANEOUS, PLAYER_DETECTOR, HIGH_SPEED_REPEATER);
FilterBuilder.addBlocks(Filters.TIANJIN_BUILDING,
ROLLING,
PLATFORM_TJ_1, PLATFORM_TJ_2, PLATFORM_TJ_1_INDENTED, PLATFORM_TJ_2_INDENTED,
Expand Down

0 comments on commit 6b11d51

Please sign in to comment.