use of net.minecraft.block.BlockRailBase.EnumRailDirection in project Railcraft by Railcraft.
the class BlockTrack method isRailValid.
protected boolean isRailValid(IBlockState state, World world, BlockPos pos, int maxSupportedDistance) {
boolean valid = true;
EnumRailDirection dir = TrackTools.getTrackDirectionRaw(state);
if (!TrackSupportTools.isSupported(world, pos, maxSupportedDistance))
valid = false;
if (maxSupportedDistance == 0) {
if (dir == ASCENDING_EAST && !world.isSideSolid(pos.east(), EnumFacing.UP))
valid = false;
else if (dir == ASCENDING_WEST && !world.isSideSolid(pos.west(), EnumFacing.UP))
valid = false;
else if (dir == ASCENDING_NORTH && !world.isSideSolid(pos.north(), EnumFacing.UP))
valid = false;
else if (dir == ASCENDING_SOUTH && !world.isSideSolid(pos.south(), EnumFacing.UP))
valid = false;
}
return valid;
}
use of net.minecraft.block.BlockRailBase.EnumRailDirection in project Railcraft by Railcraft.
the class TrackKitSwitchWye method getCartsAtSpringEntrance.
@Override
protected List<UUID> getCartsAtSpringEntrance() {
EnumRailDirection dir = getRailDirectionRaw();
BlockPos offset = getPos();
if (dir == EnumRailDirection.EAST_WEST) {
if (isMirrored()) {
offset = offset.east();
} else {
offset = offset.west();
}
} else if (dir == EnumRailDirection.NORTH_SOUTH) {
if (isMirrored()) {
offset = offset.north();
} else {
offset = offset.south();
}
}
return CartTools.getMinecartUUIDsAt(theWorldAsserted(), offset, 0.1f);
}
use of net.minecraft.block.BlockRailBase.EnumRailDirection in project Railcraft by Railcraft.
the class TrackKitSwitch method determineMirror.
protected void determineMirror() {
World world = theWorldAsserted();
EnumRailDirection dir = TrackTools.getTrackDirection(world, getPos());
boolean prevValue = isMirrored();
if (dir == EnumRailDirection.NORTH_SOUTH) {
BlockPos offset = getPos();
if (TrackTools.isRailBlockAt(world, offset.west())) {
offset = offset.west();
// West
mirrored = true;
} else {
offset = offset.east();
// East
mirrored = false;
}
if (TrackTools.isRailBlockAt(world, offset)) {
EnumRailDirection otherDir = TrackTools.getTrackDirection(world, offset);
if (otherDir == EnumRailDirection.NORTH_SOUTH)
TrackTools.setTrackDirection(world, offset, EnumRailDirection.EAST_WEST);
}
} else if (dir == EnumRailDirection.EAST_WEST)
mirrored = TrackTools.isRailBlockAt(world, getPos().north());
if (prevValue != isMirrored())
sendUpdateToClient();
}
use of net.minecraft.block.BlockRailBase.EnumRailDirection in project Railcraft by Railcraft.
the class TrackKitSwitch method determineRailDirection.
protected void determineRailDirection() {
World world = theWorldAsserted();
EnumRailDirection dir = TrackTools.getTrackDirectionRaw(world.getBlockState(getPos()));
if (TrackTools.isRailBlockAt(world, getPos().east()) && TrackTools.isRailBlockAt(world, getPos().west())) {
if (dir != EnumRailDirection.EAST_WEST)
TrackTools.setTrackDirection(world, getPos(), EnumRailDirection.EAST_WEST);
// } else if (TrackTools.isRailBlockAt(world, getPos().north()) && TrackTools.isRailBlockAt(world, getPos().south())) {
// if (dir != EnumRailDirection.NORTH_SOUTH)
// world.setBlockState(getPos(), current.withProperty(shapeProp, EnumRailDirection.NORTH_SOUTH));
} else if (dir != EnumRailDirection.NORTH_SOUTH)
TrackTools.setTrackDirection(world, getPos(), EnumRailDirection.NORTH_SOUTH);
}
use of net.minecraft.block.BlockRailBase.EnumRailDirection in project Railcraft by Railcraft.
the class TrackKitSwitchTurnout method getCartsAtDecisionEntrance.
@Override
protected List<UUID> getCartsAtDecisionEntrance() {
EnumRailDirection dir = getRailDirectionRaw();
BlockPos offset = getPos();
if (dir == EnumRailDirection.NORTH_SOUTH) {
offset = isReversed() != isMirrored() ? offset.north() : offset.south();
} else if (dir == EnumRailDirection.EAST_WEST) {
offset = isReversed() == isMirrored() ? offset.west() : offset.east();
}
return CartTools.getMinecartUUIDsAt(theWorldAsserted(), offset, 0.1f);
}
Aggregations