Search in sources :

Example 1 with EnumRailDirection

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;
}
Also used : EnumRailDirection(net.minecraft.block.BlockRailBase.EnumRailDirection)

Example 2 with EnumRailDirection

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);
}
Also used : EnumRailDirection(net.minecraft.block.BlockRailBase.EnumRailDirection) BlockPos(net.minecraft.util.math.BlockPos)

Example 3 with EnumRailDirection

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();
}
Also used : EnumRailDirection(net.minecraft.block.BlockRailBase.EnumRailDirection) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 4 with EnumRailDirection

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);
}
Also used : EnumRailDirection(net.minecraft.block.BlockRailBase.EnumRailDirection) World(net.minecraft.world.World)

Example 5 with EnumRailDirection

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);
}
Also used : EnumRailDirection(net.minecraft.block.BlockRailBase.EnumRailDirection) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

EnumRailDirection (net.minecraft.block.BlockRailBase.EnumRailDirection)15 BlockPos (net.minecraft.util.math.BlockPos)8 IBlockState (net.minecraft.block.state.IBlockState)2 EnumFacing (net.minecraft.util.EnumFacing)2 World (net.minecraft.world.World)2 HashSet (java.util.HashSet)1 EntityLocomotive (mods.railcraft.common.carts.EntityLocomotive)1 Vec3d (net.minecraft.util.math.Vec3d)1