Search in sources :

Example 1 with AbstractRailBlock

use of net.minecraft.block.AbstractRailBlock in project minecolonies by ldtteam.

the class MinecoloniesAdvancedPathNavigate method handlePathOnRails.

/**
 * Handle pathing on rails.
 *
 * @param pEx     the current path point.
 * @param pExNext the next path point.
 * @return if go to next point.
 */
private boolean handlePathOnRails(final PathPointExtended pEx, final PathPointExtended pExNext) {
    if (pEx.isRailsEntry()) {
        final BlockPos blockPos = new BlockPos(pEx.x, pEx.y, pEx.z);
        if (!spawnedPos.equals(blockPos)) {
            final BlockState blockstate = level.getBlockState(blockPos);
            RailShape railshape = blockstate.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock) blockstate.getBlock()).getRailDirection(blockstate, level, blockPos, null) : RailShape.NORTH_SOUTH;
            double yOffset = 0.0D;
            if (railshape.isAscending()) {
                yOffset = 0.5D;
            }
            if (mob.vehicle instanceof MinecoloniesMinecart) {
                ((MinecoloniesMinecart) mob.vehicle).setHurtDir(1);
            } else {
                MinecoloniesMinecart minecart = (MinecoloniesMinecart) ModEntities.MINECART.create(level);
                final double x = pEx.x + 0.5D;
                final double y = pEx.y + 0.625D + yOffset;
                final double z = pEx.z + 0.5D;
                minecart.setPos(x, y, z);
                minecart.setDeltaMovement(Vector3d.ZERO);
                minecart.xo = x;
                minecart.yo = y;
                minecart.zo = z;
                level.addFreshEntity(minecart);
                minecart.setHurtDir(1);
                mob.startRiding(minecart, true);
            }
            spawnedPos = blockPos;
        }
    } else {
        spawnedPos = BlockPos.ZERO;
    }
    if (mob.vehicle instanceof MinecoloniesMinecart && pExNext != null) {
        final BlockPos blockPos = new BlockPos(pEx.x, pEx.y, pEx.z);
        final BlockPos blockPosNext = new BlockPos(pExNext.x, pExNext.y, pExNext.z);
        final Vector3d motion = mob.vehicle.getDeltaMovement();
        double forward;
        switch(BlockPosUtil.getXZFacing(blockPos, blockPosNext).getOpposite()) {
            case EAST:
                forward = Math.min(Math.max(motion.x() - 1 * 0.01D, -1), 0);
                mob.vehicle.setDeltaMovement(motion.add(forward == -1 ? -1 : -0.01D, 0.0D, 0.0D));
                break;
            case WEST:
                forward = Math.max(Math.min(motion.x() + 0.01D, 1), 0);
                mob.vehicle.setDeltaMovement(motion.add(forward == 1 ? 1 : 0.01D, 0.0D, 0.0D));
                break;
            case NORTH:
                forward = Math.max(Math.min(motion.z() + 0.01D, 1), 0);
                mob.vehicle.setDeltaMovement(motion.add(0.0D, 0.0D, forward == 1 ? 1 : 0.01D));
                break;
            case SOUTH:
                forward = Math.min(Math.max(motion.z() - 1 * 0.01D, -1), 0);
                mob.vehicle.setDeltaMovement(motion.add(0.0D, 0.0D, forward == -1 ? -1 : -0.01D));
                break;
            case DOWN:
            case UP:
                // unreachable
                break;
        }
    }
    return false;
}
Also used : BlockState(net.minecraft.block.BlockState) Vector3d(net.minecraft.util.math.vector.Vector3d) RailShape(net.minecraft.state.properties.RailShape) BlockPos(net.minecraft.util.math.BlockPos) MinecoloniesMinecart(com.minecolonies.api.entity.MinecoloniesMinecart) AbstractRailBlock(net.minecraft.block.AbstractRailBlock)

Example 2 with AbstractRailBlock

use of net.minecraft.block.AbstractRailBlock in project minecolonies by ldtteam.

the class MinecoloniesMinecart method moveAlongTrack.

@Override
protected void moveAlongTrack(BlockPos pos, BlockState state) {
    this.fallDistance = 0.0F;
    double x = this.getX();
    double y = this.getY();
    double z = this.getZ();
    Vector3d posVec = this.getPos(x, y, z);
    y = pos.getY();
    boolean isPowered = false;
    boolean flag = false;
    AbstractRailBlock abstractrailblock = (AbstractRailBlock) state.getBlock();
    if (abstractrailblock instanceof PoweredRailBlock && !((PoweredRailBlock) abstractrailblock).isActivatorRail()) {
        isPowered = state.getValue(PoweredRailBlock.POWERED);
        flag = !isPowered;
    }
    RailShape railshape = ((AbstractRailBlock) state.getBlock()).getRailDirection(state, this.level, pos, this);
    switch(railshape) {
        case ASCENDING_EAST:
        case ASCENDING_WEST:
        case ASCENDING_NORTH:
        case ASCENDING_SOUTH:
            ++y;
            break;
        default:
            break;
    }
    Vector3d motion = this.getDeltaMovement();
    Pair<Vector3i, Vector3i> pair = getShapeMatrix(railshape);
    Vector3i vecIn = pair.getFirst();
    Vector3i vecOut = pair.getSecond();
    double xDif = (vecOut.getX() - vecIn.getX());
    double zDif = (vecOut.getZ() - vecIn.getZ());
    double difSq = Math.sqrt(xDif * xDif + zDif * zDif);
    double difMotion = motion.x * xDif + motion.z * zDif;
    if (difMotion < 0.0D) {
        xDif = -xDif;
        zDif = -zDif;
    }
    double veloc = Math.min(2.0D, Math.sqrt(getHorizontalDistanceSqr(motion)));
    motion = new Vector3d(veloc * xDif / difSq, motion.y, veloc * zDif / difSq);
    this.setDeltaMovement(motion);
    if (flag && shouldDoRailFunctions()) {
        double tempMot = Math.sqrt(getHorizontalDistanceSqr(this.getDeltaMovement()));
        if (tempMot < 0.03D) {
            this.setDeltaMovement(Vector3d.ZERO);
        } else {
            this.setDeltaMovement(this.getDeltaMovement().multiply(0.5D, 0.0D, 0.5D));
        }
    }
    double xInDif = (double) pos.getX() + 0.5D + (double) vecIn.getX() * 0.5D;
    double zInDif = (double) pos.getZ() + 0.5D + (double) vecIn.getZ() * 0.5D;
    double xOutDif = (double) pos.getX() + 0.5D + (double) vecOut.getX() * 0.5D;
    double zOutDif = (double) pos.getZ() + 0.5D + (double) vecOut.getZ() * 0.5D;
    xDif = xOutDif - xInDif;
    zDif = zOutDif - zInDif;
    double xzDif;
    if (xDif == 0.0D) {
        xzDif = z - (double) pos.getZ();
    } else if (zDif == 0.0D) {
        xzDif = x - (double) pos.getX();
    } else {
        double d15 = x - xInDif;
        double d16 = z - zInDif;
        xzDif = (d15 * xDif + d16 * zDif) * 2.0D;
    }
    x = xInDif + xDif * xzDif;
    z = zInDif + zDif * xzDif;
    this.setPos(x, y, z);
    this.moveMinecartOnRail(pos);
    if (vecIn.getY() != 0 && MathHelper.floor(this.getX()) - pos.getX() == vecIn.getX() && MathHelper.floor(this.getZ()) - pos.getZ() == vecIn.getZ()) {
        this.setPos(this.getX(), this.getY() + (double) vecIn.getY(), this.getZ());
    } else if (vecOut.getY() != 0 && MathHelper.floor(this.getX()) - pos.getX() == vecOut.getX() && MathHelper.floor(this.getZ()) - pos.getZ() == vecOut.getZ()) {
        this.setPos(this.getX(), this.getY() + (double) vecOut.getY(), this.getZ());
    }
    this.applyNaturalSlowdown();
    Vector3d newPos = this.getPos(this.getX(), this.getY(), this.getZ());
    if (newPos != null && posVec != null) {
        double yMot = (posVec.y - newPos.y) * 0.05D;
        Vector3d tempMot = this.getDeltaMovement();
        double tempVeloc = Math.sqrt(getHorizontalDistanceSqr(tempMot));
        if (tempVeloc > 0.0D) {
            this.setDeltaMovement(tempMot.multiply((tempVeloc + yMot) / tempVeloc, 1.0D, (tempVeloc + yMot) / tempVeloc));
        }
        this.setPos(this.getX(), newPos.y, this.getZ());
    }
    int xFloor = MathHelper.floor(this.getX());
    int zFloor = MathHelper.floor(this.getZ());
    if (xFloor != pos.getX() || zFloor != pos.getZ()) {
        Vector3d tempMot = this.getDeltaMovement();
        double temoVeloc = Math.sqrt(getHorizontalDistanceSqr(tempMot));
        this.setDeltaMovement(temoVeloc * (double) (xFloor - pos.getX()), tempMot.y, temoVeloc * (double) (zFloor - pos.getZ()));
    }
    if (shouldDoRailFunctions()) {
        ((AbstractRailBlock) state.getBlock()).onMinecartPass(state, level, pos, this);
    }
    if (isPowered && shouldDoRailFunctions()) {
        Vector3d tempMot = this.getDeltaMovement();
        double tempVeloc = Math.sqrt(getHorizontalDistanceSqr(tempMot));
        if (tempVeloc > 0.01D) {
            this.setDeltaMovement(tempMot.add(tempMot.x / tempVeloc * 0.06D, 0.0D, tempMot.z / tempVeloc * 0.06D));
        } else {
            Vector3d mot = this.getDeltaMovement();
            double tempX = mot.x;
            double tempZ = mot.z;
            if (railshape == RailShape.EAST_WEST) {
                if (this.isNormalCube(pos.west())) {
                    tempX = 0.02D;
                } else if (this.isNormalCube(pos.east())) {
                    tempX = -0.02D;
                }
            } else {
                if (railshape != RailShape.NORTH_SOUTH) {
                    return;
                }
                if (this.isNormalCube(pos.north())) {
                    tempZ = 0.02D;
                } else if (this.isNormalCube(pos.south())) {
                    tempZ = -0.02D;
                }
            }
            this.setDeltaMovement(tempX, mot.y, tempZ);
        }
    }
}
Also used : PoweredRailBlock(net.minecraft.block.PoweredRailBlock) Vector3d(net.minecraft.util.math.vector.Vector3d) RailShape(net.minecraft.state.properties.RailShape) Vector3i(net.minecraft.util.math.vector.Vector3i) AbstractRailBlock(net.minecraft.block.AbstractRailBlock)

Example 3 with AbstractRailBlock

use of net.minecraft.block.AbstractRailBlock in project minecolonies by Minecolonies.

the class MinecoloniesMinecart method moveAlongTrack.

@Override
protected void moveAlongTrack(BlockPos pos, BlockState state) {
    this.fallDistance = 0.0F;
    double x = this.getX();
    double y = this.getY();
    double z = this.getZ();
    Vector3d posVec = this.getPos(x, y, z);
    y = pos.getY();
    boolean isPowered = false;
    boolean flag = false;
    AbstractRailBlock abstractrailblock = (AbstractRailBlock) state.getBlock();
    if (abstractrailblock instanceof PoweredRailBlock && !((PoweredRailBlock) abstractrailblock).isActivatorRail()) {
        isPowered = state.getValue(PoweredRailBlock.POWERED);
        flag = !isPowered;
    }
    RailShape railshape = ((AbstractRailBlock) state.getBlock()).getRailDirection(state, this.level, pos, this);
    switch(railshape) {
        case ASCENDING_EAST:
        case ASCENDING_WEST:
        case ASCENDING_NORTH:
        case ASCENDING_SOUTH:
            ++y;
            break;
        default:
            break;
    }
    Vector3d motion = this.getDeltaMovement();
    Pair<Vector3i, Vector3i> pair = getShapeMatrix(railshape);
    Vector3i vecIn = pair.getFirst();
    Vector3i vecOut = pair.getSecond();
    double xDif = (vecOut.getX() - vecIn.getX());
    double zDif = (vecOut.getZ() - vecIn.getZ());
    double difSq = Math.sqrt(xDif * xDif + zDif * zDif);
    double difMotion = motion.x * xDif + motion.z * zDif;
    if (difMotion < 0.0D) {
        xDif = -xDif;
        zDif = -zDif;
    }
    double veloc = Math.min(2.0D, Math.sqrt(getHorizontalDistanceSqr(motion)));
    motion = new Vector3d(veloc * xDif / difSq, motion.y, veloc * zDif / difSq);
    this.setDeltaMovement(motion);
    if (flag && shouldDoRailFunctions()) {
        double tempMot = Math.sqrt(getHorizontalDistanceSqr(this.getDeltaMovement()));
        if (tempMot < 0.03D) {
            this.setDeltaMovement(Vector3d.ZERO);
        } else {
            this.setDeltaMovement(this.getDeltaMovement().multiply(0.5D, 0.0D, 0.5D));
        }
    }
    double xInDif = (double) pos.getX() + 0.5D + (double) vecIn.getX() * 0.5D;
    double zInDif = (double) pos.getZ() + 0.5D + (double) vecIn.getZ() * 0.5D;
    double xOutDif = (double) pos.getX() + 0.5D + (double) vecOut.getX() * 0.5D;
    double zOutDif = (double) pos.getZ() + 0.5D + (double) vecOut.getZ() * 0.5D;
    xDif = xOutDif - xInDif;
    zDif = zOutDif - zInDif;
    double xzDif;
    if (xDif == 0.0D) {
        xzDif = z - (double) pos.getZ();
    } else if (zDif == 0.0D) {
        xzDif = x - (double) pos.getX();
    } else {
        double d15 = x - xInDif;
        double d16 = z - zInDif;
        xzDif = (d15 * xDif + d16 * zDif) * 2.0D;
    }
    x = xInDif + xDif * xzDif;
    z = zInDif + zDif * xzDif;
    this.setPos(x, y, z);
    this.moveMinecartOnRail(pos);
    if (vecIn.getY() != 0 && MathHelper.floor(this.getX()) - pos.getX() == vecIn.getX() && MathHelper.floor(this.getZ()) - pos.getZ() == vecIn.getZ()) {
        this.setPos(this.getX(), this.getY() + (double) vecIn.getY(), this.getZ());
    } else if (vecOut.getY() != 0 && MathHelper.floor(this.getX()) - pos.getX() == vecOut.getX() && MathHelper.floor(this.getZ()) - pos.getZ() == vecOut.getZ()) {
        this.setPos(this.getX(), this.getY() + (double) vecOut.getY(), this.getZ());
    }
    this.applyNaturalSlowdown();
    Vector3d newPos = this.getPos(this.getX(), this.getY(), this.getZ());
    if (newPos != null && posVec != null) {
        double yMot = (posVec.y - newPos.y) * 0.05D;
        Vector3d tempMot = this.getDeltaMovement();
        double tempVeloc = Math.sqrt(getHorizontalDistanceSqr(tempMot));
        if (tempVeloc > 0.0D) {
            this.setDeltaMovement(tempMot.multiply((tempVeloc + yMot) / tempVeloc, 1.0D, (tempVeloc + yMot) / tempVeloc));
        }
        this.setPos(this.getX(), newPos.y, this.getZ());
    }
    int xFloor = MathHelper.floor(this.getX());
    int zFloor = MathHelper.floor(this.getZ());
    if (xFloor != pos.getX() || zFloor != pos.getZ()) {
        Vector3d tempMot = this.getDeltaMovement();
        double temoVeloc = Math.sqrt(getHorizontalDistanceSqr(tempMot));
        this.setDeltaMovement(temoVeloc * (double) (xFloor - pos.getX()), tempMot.y, temoVeloc * (double) (zFloor - pos.getZ()));
    }
    if (shouldDoRailFunctions()) {
        ((AbstractRailBlock) state.getBlock()).onMinecartPass(state, level, pos, this);
    }
    if (isPowered && shouldDoRailFunctions()) {
        Vector3d tempMot = this.getDeltaMovement();
        double tempVeloc = Math.sqrt(getHorizontalDistanceSqr(tempMot));
        if (tempVeloc > 0.01D) {
            this.setDeltaMovement(tempMot.add(tempMot.x / tempVeloc * 0.06D, 0.0D, tempMot.z / tempVeloc * 0.06D));
        } else {
            Vector3d mot = this.getDeltaMovement();
            double tempX = mot.x;
            double tempZ = mot.z;
            if (railshape == RailShape.EAST_WEST) {
                if (this.isNormalCube(pos.west())) {
                    tempX = 0.02D;
                } else if (this.isNormalCube(pos.east())) {
                    tempX = -0.02D;
                }
            } else {
                if (railshape != RailShape.NORTH_SOUTH) {
                    return;
                }
                if (this.isNormalCube(pos.north())) {
                    tempZ = 0.02D;
                } else if (this.isNormalCube(pos.south())) {
                    tempZ = -0.02D;
                }
            }
            this.setDeltaMovement(tempX, mot.y, tempZ);
        }
    }
}
Also used : PoweredRailBlock(net.minecraft.block.PoweredRailBlock) Vector3d(net.minecraft.util.math.vector.Vector3d) RailShape(net.minecraft.state.properties.RailShape) Vector3i(net.minecraft.util.math.vector.Vector3i) AbstractRailBlock(net.minecraft.block.AbstractRailBlock)

Example 4 with AbstractRailBlock

use of net.minecraft.block.AbstractRailBlock in project minecolonies by Minecolonies.

the class MinecoloniesAdvancedPathNavigate method handlePathOnRails.

/**
 * Handle pathing on rails.
 *
 * @param pEx     the current path point.
 * @param pExNext the next path point.
 * @return if go to next point.
 */
private boolean handlePathOnRails(final PathPointExtended pEx, final PathPointExtended pExNext) {
    if (pEx.isRailsEntry()) {
        final BlockPos blockPos = new BlockPos(pEx.x, pEx.y, pEx.z);
        if (!spawnedPos.equals(blockPos)) {
            final BlockState blockstate = level.getBlockState(blockPos);
            RailShape railshape = blockstate.getBlock() instanceof AbstractRailBlock ? ((AbstractRailBlock) blockstate.getBlock()).getRailDirection(blockstate, level, blockPos, null) : RailShape.NORTH_SOUTH;
            double yOffset = 0.0D;
            if (railshape.isAscending()) {
                yOffset = 0.5D;
            }
            if (mob.vehicle instanceof MinecoloniesMinecart) {
                ((MinecoloniesMinecart) mob.vehicle).setHurtDir(1);
            } else {
                MinecoloniesMinecart minecart = (MinecoloniesMinecart) ModEntities.MINECART.create(level);
                final double x = pEx.x + 0.5D;
                final double y = pEx.y + 0.625D + yOffset;
                final double z = pEx.z + 0.5D;
                minecart.setPos(x, y, z);
                minecart.setDeltaMovement(Vector3d.ZERO);
                minecart.xo = x;
                minecart.yo = y;
                minecart.zo = z;
                level.addFreshEntity(minecart);
                minecart.setHurtDir(1);
                mob.startRiding(minecart, true);
            }
            spawnedPos = blockPos;
        }
    } else {
        spawnedPos = BlockPos.ZERO;
    }
    if (mob.vehicle instanceof MinecoloniesMinecart && pExNext != null) {
        final BlockPos blockPos = new BlockPos(pEx.x, pEx.y, pEx.z);
        final BlockPos blockPosNext = new BlockPos(pExNext.x, pExNext.y, pExNext.z);
        final Vector3d motion = mob.vehicle.getDeltaMovement();
        double forward;
        switch(BlockPosUtil.getXZFacing(blockPos, blockPosNext).getOpposite()) {
            case EAST:
                forward = Math.min(Math.max(motion.x() - 1 * 0.01D, -1), 0);
                mob.vehicle.setDeltaMovement(motion.add(forward == -1 ? -1 : -0.01D, 0.0D, 0.0D));
                break;
            case WEST:
                forward = Math.max(Math.min(motion.x() + 0.01D, 1), 0);
                mob.vehicle.setDeltaMovement(motion.add(forward == 1 ? 1 : 0.01D, 0.0D, 0.0D));
                break;
            case NORTH:
                forward = Math.max(Math.min(motion.z() + 0.01D, 1), 0);
                mob.vehicle.setDeltaMovement(motion.add(0.0D, 0.0D, forward == 1 ? 1 : 0.01D));
                break;
            case SOUTH:
                forward = Math.min(Math.max(motion.z() - 1 * 0.01D, -1), 0);
                mob.vehicle.setDeltaMovement(motion.add(0.0D, 0.0D, forward == -1 ? -1 : -0.01D));
                break;
            case DOWN:
            case UP:
                // unreachable
                break;
        }
    }
    return false;
}
Also used : BlockState(net.minecraft.block.BlockState) Vector3d(net.minecraft.util.math.vector.Vector3d) RailShape(net.minecraft.state.properties.RailShape) BlockPos(net.minecraft.util.math.BlockPos) MinecoloniesMinecart(com.minecolonies.api.entity.MinecoloniesMinecart) AbstractRailBlock(net.minecraft.block.AbstractRailBlock)

Example 5 with AbstractRailBlock

use of net.minecraft.block.AbstractRailBlock in project ChocolateQuestRepoured by TeamChocoQuest.

the class PathNavigateGroundCQR method getPathFinder.

@Override
protected PathFinder getPathFinder() {
    this.nodeProcessor = new WalkNodeProcessor() {

        @Override
        public PathNodeType getPathNodeType(IBlockAccess p_193577_1_, int x, int y, int z, int xSize, int ySize, int zSize, boolean canOpenDoorsIn, boolean canEnterDoorsIn, EnumSet<PathNodeType> p_193577_10_, PathNodeType p_193577_11_, BlockPos p_193577_12_) {
            for (int i = 0; i < xSize; ++i) {
                for (int j = 0; j < ySize; ++j) {
                    for (int k = 0; k < zSize; ++k) {
                        int l = i + x;
                        int i1 = j + y;
                        int j1 = k + z;
                        PathNodeType pathnodetype = this.getPathNodeType(p_193577_1_, l, i1, j1);
                        if (pathnodetype == PathNodeType.DOOR_WOOD_CLOSED && canOpenDoorsIn && canEnterDoorsIn) {
                            pathnodetype = PathNodeType.WALKABLE;
                        }
                        // TODO better method for calculating the facing from which the door will be entered
                        if (pathnodetype == PathNodeType.DOOR_IRON_CLOSED && canOpenDoorsIn && canEnterDoorsIn && EntityAIOpenCloseDoor.canMoveThroughDoor(p_193577_1_, new BlockPos(l, i1, j1), Direction.getFacingFromVector(l - p_193577_12_.getX(), i1 - p_193577_12_.getY(), j1 - p_193577_12_.getZ()).getOpposite(), true)) {
                            pathnodetype = PathNodeType.WALKABLE;
                        }
                        if (pathnodetype == PathNodeType.DOOR_OPEN && !canEnterDoorsIn) {
                            pathnodetype = PathNodeType.BLOCKED;
                        }
                        if (pathnodetype == PathNodeType.RAIL && !(p_193577_1_.getBlockState(p_193577_12_).getBlock() instanceof AbstractRailBlock) && !(p_193577_1_.getBlockState(p_193577_12_.down()).getBlock() instanceof AbstractRailBlock)) {
                            pathnodetype = PathNodeType.FENCE;
                        }
                        if (i == 0 && j == 0 && k == 0) {
                            p_193577_11_ = pathnodetype;
                        }
                        p_193577_10_.add(pathnodetype);
                    }
                }
            }
            return p_193577_11_;
        }

        @Override
        protected PathNodeType getPathNodeTypeRaw(IBlockAccess p_189553_1_, int p_189553_2_, int p_189553_3_, int p_189553_4_) {
            BlockPos blockpos = new BlockPos(p_189553_2_, p_189553_3_, p_189553_4_);
            BlockState iblockstate = p_189553_1_.getBlockState(blockpos);
            Block block = iblockstate.getBlock();
            Material material = iblockstate.getMaterial();
            PathNodeType type = block.getAiPathNodeType(iblockstate, p_189553_1_, blockpos, this.currentEntity);
            if (type != null) {
                return type;
            }
            if (material == Material.AIR) {
                return PathNodeType.OPEN;
            } else if (block != Blocks.TRAPDOOR && block != Blocks.IRON_TRAPDOOR && block != Blocks.WATERLILY) {
                if (block == Blocks.FIRE) {
                    return PathNodeType.DAMAGE_FIRE;
                } else if (block == Blocks.CACTUS) {
                    return PathNodeType.DAMAGE_CACTUS;
                } else if (block instanceof DoorBlock && material == Material.WOOD && !iblockstate.getActualState(p_189553_1_, blockpos).getValue(DoorBlock.OPEN)) {
                    return PathNodeType.DOOR_WOOD_CLOSED;
                } else if (block instanceof DoorBlock && material == Material.IRON && !iblockstate.getActualState(p_189553_1_, blockpos).getValue(DoorBlock.OPEN)) {
                    return PathNodeType.DOOR_IRON_CLOSED;
                } else if (block instanceof DoorBlock && iblockstate.getActualState(p_189553_1_, blockpos).getValue(DoorBlock.OPEN)) {
                    return PathNodeType.DOOR_OPEN;
                } else if (block instanceof AbstractRailBlock) {
                    return PathNodeType.RAIL;
                } else if (!(block instanceof FenceBlock) && !(block instanceof WallBlock) && (!(block instanceof FenceGateBlock) || iblockstate.getValue(FenceGateBlock.OPEN).booleanValue())) {
                    if (material == Material.WATER) {
                        return PathNodeType.WATER;
                    } else if (material == Material.LAVA) {
                        return PathNodeType.LAVA;
                    } else {
                        return block.isPassable(p_189553_1_, blockpos) ? PathNodeType.OPEN : PathNodeType.BLOCKED;
                    }
                } else {
                    return PathNodeType.FENCE;
                }
            } else {
                return PathNodeType.TRAPDOOR;
            }
        }
    };
    this.nodeProcessor.setCanEnterDoors(true);
    this.pathFinder = new PathFinder(this.nodeProcessor);
    return this.pathFinder;
}
Also used : IBlockAccess(net.minecraft.world.IBlockAccess) PathNodeType(net.minecraft.pathfinding.PathNodeType) Material(net.minecraft.block.material.Material) PathFinder(net.minecraft.pathfinding.PathFinder) AbstractRailBlock(net.minecraft.block.AbstractRailBlock) PathPoint(net.minecraft.pathfinding.PathPoint) WalkNodeProcessor(net.minecraft.pathfinding.WalkNodeProcessor) FenceBlock(net.minecraft.block.FenceBlock) BlockState(net.minecraft.block.BlockState) WallBlock(net.minecraft.block.WallBlock) DoorBlock(net.minecraft.block.DoorBlock) AbstractRailBlock(net.minecraft.block.AbstractRailBlock) FenceBlock(net.minecraft.block.FenceBlock) WallBlock(net.minecraft.block.WallBlock) BlockPos(net.minecraft.util.math.BlockPos) DoorBlock(net.minecraft.block.DoorBlock)

Aggregations

AbstractRailBlock (net.minecraft.block.AbstractRailBlock)7 RailShape (net.minecraft.state.properties.RailShape)5 BlockState (net.minecraft.block.BlockState)4 BlockPos (net.minecraft.util.math.BlockPos)4 Vector3d (net.minecraft.util.math.vector.Vector3d)4 MinecoloniesMinecart (com.minecolonies.api.entity.MinecoloniesMinecart)2 PoweredRailBlock (net.minecraft.block.PoweredRailBlock)2 AbstractMinecartEntity (net.minecraft.entity.item.minecart.AbstractMinecartEntity)2 Vector3i (net.minecraft.util.math.vector.Vector3i)2 HashMap (java.util.HashMap)1 Block (net.minecraft.block.Block)1 DoorBlock (net.minecraft.block.DoorBlock)1 FenceBlock (net.minecraft.block.FenceBlock)1 WallBlock (net.minecraft.block.WallBlock)1 Material (net.minecraft.block.material.Material)1 ItemStack (net.minecraft.item.ItemStack)1 PathFinder (net.minecraft.pathfinding.PathFinder)1 PathNodeType (net.minecraft.pathfinding.PathNodeType)1 PathPoint (net.minecraft.pathfinding.PathPoint)1 WalkNodeProcessor (net.minecraft.pathfinding.WalkNodeProcessor)1