Skip to content

Commit

Permalink
API cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sm0keySa1m0n committed Sep 6, 2023
1 parent 6bb8528 commit b039329
Show file tree
Hide file tree
Showing 15 changed files with 181 additions and 352 deletions.
17 changes: 0 additions & 17 deletions src/api/java/mods/railcraft/api/core/ClientAccessException.java

This file was deleted.

158 changes: 0 additions & 158 deletions src/api/java/mods/railcraft/api/core/DimensionPos.java

This file was deleted.

6 changes: 5 additions & 1 deletion src/api/java/mods/railcraft/api/track/ArrowDirection.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

public enum ArrowDirection implements StringRepresentable {

NORTH("north"), SOUTH("south"), EAST("east"), WEST("west"), NORTH_SOUTH("north_south"),
NORTH("north"),
SOUTH("south"),
EAST("east"),
WEST("west"),
NORTH_SOUTH("north_south"),
EAST_WEST("east_west");

private final String name;
Expand Down
16 changes: 0 additions & 16 deletions src/api/java/mods/railcraft/api/track/BlockingTrack.java

This file was deleted.

34 changes: 15 additions & 19 deletions src/api/java/mods/railcraft/api/track/RailShapeUtil.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
package mods.railcraft.api.track;

import javax.annotation.Nullable;
import net.minecraft.world.level.block.state.properties.RailShape;

public final class RailShapeUtil {

private RailShapeUtil() {}

public static boolean isLevelStraight(@Nullable RailShape dir) {
return dir != null && dir.ordinal() < 2;
public static boolean isLevelStraight(RailShape railShape) {
return railShape == RailShape.NORTH_SOUTH || railShape == RailShape.EAST_WEST;
}

public static boolean isStraight(@Nullable RailShape dir) {
return dir != null && dir.ordinal() < 6;
public static boolean isEastWest(RailShape railShape) {
return (railShape == RailShape.EAST_WEST
|| railShape == RailShape.ASCENDING_EAST
|| railShape == RailShape.ASCENDING_WEST);
}

public static boolean isEastWest(@Nullable RailShape dir) {
return (dir == RailShape.EAST_WEST || dir == RailShape.ASCENDING_EAST
|| dir == RailShape.ASCENDING_WEST);
public static boolean isNorthSouth(RailShape railShape) {
return (railShape == RailShape.NORTH_SOUTH
|| railShape == RailShape.ASCENDING_NORTH
|| railShape == RailShape.ASCENDING_SOUTH);
}

public static boolean isNorthSouth(@Nullable RailShape dir) {
return (dir == RailShape.NORTH_SOUTH || dir == RailShape.ASCENDING_NORTH
|| dir == RailShape.ASCENDING_SOUTH);
}

public static boolean isAscending(@Nullable RailShape dir) {
return dir != null && dir.isAscending();
}

public static boolean isTurn(@Nullable RailShape dir) {
return dir != null && dir.ordinal() >= 6;
public static boolean isTurn(RailShape railShape) {
return railShape == RailShape.SOUTH_EAST
|| railShape == RailShape.SOUTH_WEST
|| railShape == RailShape.NORTH_WEST
|| railShape == RailShape.NORTH_EAST;
}
}
2 changes: 1 addition & 1 deletion src/api/java/mods/railcraft/api/track/TrackUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static TrackType getTrackType(ItemStack stack) {

public static boolean isStraightTrackAt(BlockGetter level, BlockPos pos) {
return BaseRailBlock.isRail(level.getBlockState(pos))
&& RailShapeUtil.isStraight(getTrackDirection(level, pos));
&& !RailShapeUtil.isTurn(getTrackDirection(level, pos));
}

public static boolean isRail(ItemStack stack) {
Expand Down

0 comments on commit b039329

Please sign in to comment.