Search in sources :

Example 1 with IGoalRenderPos

use of baritone.api.utils.interfaces.IGoalRenderPos in project Spark-Client by Spark-Client-Development.

the class PathRenderer method drawDankLitGoalBox.

public static void drawDankLitGoalBox(Entity player, Goal goal, float partialTicks, Color color) {
    double renderPosX = renderManager.viewerPosX;
    double renderPosY = renderManager.viewerPosY;
    double renderPosZ = renderManager.viewerPosZ;
    double minX, maxX;
    double minZ, maxZ;
    double minY, maxY;
    double y1, y2;
    double y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2));
    if (goal instanceof IGoalRenderPos) {
        BlockPos goalPos = ((IGoalRenderPos) goal).getGoalPos();
        minX = goalPos.getX() + 0.002 - renderPosX;
        maxX = goalPos.getX() + 1 - 0.002 - renderPosX;
        minZ = goalPos.getZ() + 0.002 - renderPosZ;
        maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ;
        if (goal instanceof GoalGetToBlock || goal instanceof GoalTwoBlocks) {
            y /= 2;
        }
        y1 = 1 + y + goalPos.getY() - renderPosY;
        y2 = 1 - y + goalPos.getY() - renderPosY;
        minY = goalPos.getY() - renderPosY;
        maxY = minY + 2;
        if (goal instanceof GoalGetToBlock || goal instanceof GoalTwoBlocks) {
            y1 -= 0.5;
            y2 -= 0.5;
            maxY--;
        }
    } else if (goal instanceof GoalXZ) {
        GoalXZ goalPos = (GoalXZ) goal;
        if (settings.renderGoalXZBeacon.getValue()) {
            glPushAttrib(GL_LIGHTING_BIT);
            Helper.mc.getTextureManager().bindTexture(TileEntityBeaconRenderer.TEXTURE_BEACON_BEAM);
            if (settings.renderGoalIgnoreDepth.getValue()) {
                GlStateManager.disableDepth();
            }
            TileEntityBeaconRenderer.renderBeamSegment(goalPos.getX() - renderPosX, -renderPosY, goalPos.getZ() - renderPosZ, partialTicks, 1.0, player.world.getTotalWorldTime(), 0, 256, color.getColorComponents(null));
            if (settings.renderGoalIgnoreDepth.getValue()) {
                GlStateManager.enableDepth();
            }
            glPopAttrib();
            return;
        }
        minX = goalPos.getX() + 0.002 - renderPosX;
        maxX = goalPos.getX() + 1 - 0.002 - renderPosX;
        minZ = goalPos.getZ() + 0.002 - renderPosZ;
        maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ;
        y1 = 0;
        y2 = 0;
        minY = 0 - renderPosY;
        maxY = 256 - renderPosY;
    } else if (goal instanceof GoalComposite) {
        for (Goal g : ((GoalComposite) goal).goals()) {
            drawDankLitGoalBox(player, g, partialTicks, color);
        }
        return;
    } else if (goal instanceof GoalInverted) {
        drawDankLitGoalBox(player, ((GoalInverted) goal).origin, partialTicks, settings.colorInvertedGoalBox.getValue());
        return;
    } else if (goal instanceof GoalYLevel) {
        GoalYLevel goalpos = (GoalYLevel) goal;
        minX = player.posX - settings.yLevelBoxSize.getValue() - renderPosX;
        minZ = player.posZ - settings.yLevelBoxSize.getValue() - renderPosZ;
        maxX = player.posX + settings.yLevelBoxSize.getValue() - renderPosX;
        maxZ = player.posZ + settings.yLevelBoxSize.getValue() - renderPosZ;
        minY = ((GoalYLevel) goal).level - renderPosY;
        maxY = minY + 2;
        y1 = 1 + y + goalpos.level - renderPosY;
        y2 = 1 - y + goalpos.level - renderPosY;
    } else {
        return;
    }
    IRenderer.startLines(color, settings.goalRenderLineWidthPixels.getValue().floatValue(), settings.renderGoalIgnoreDepth.getValue());
    renderHorizontalQuad(minX, maxX, minZ, maxZ, y1);
    renderHorizontalQuad(minX, maxX, minZ, maxZ, y2);
    buffer.begin(GL_LINES, DefaultVertexFormats.POSITION);
    buffer.pos(minX, minY, minZ).endVertex();
    buffer.pos(minX, maxY, minZ).endVertex();
    buffer.pos(maxX, minY, minZ).endVertex();
    buffer.pos(maxX, maxY, minZ).endVertex();
    buffer.pos(maxX, minY, maxZ).endVertex();
    buffer.pos(maxX, maxY, maxZ).endVertex();
    buffer.pos(minX, minY, maxZ).endVertex();
    buffer.pos(minX, maxY, maxZ).endVertex();
    tessellator.draw();
    IRenderer.endLines(settings.renderGoalIgnoreDepth.getValue());
}
Also used : IGoalRenderPos(baritone.api.utils.interfaces.IGoalRenderPos) BlockPos(net.minecraft.util.math.BlockPos) BetterBlockPos(baritone.api.utils.BetterBlockPos)

Example 2 with IGoalRenderPos

use of baritone.api.utils.interfaces.IGoalRenderPos in project Spark-Client by Spark-Client-Development.

the class PathingBehavior method createPathfinder.

private static AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal, IPath previous, CalculationContext context) {
    Goal transformed = goal;
    if (Baritone.settings().simplifyUnloadedYCoord.getValue() && goal instanceof IGoalRenderPos) {
        BlockPos pos = ((IGoalRenderPos) goal).getGoalPos();
        if (!context.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ())) {
            transformed = new GoalXZ(pos.getX(), pos.getZ());
        }
    }
    Favoring favoring = new Favoring(context.getBaritone().getPlayerContext(), previous, context);
    return new AStarPathFinder(start.getX(), start.getY(), start.getZ(), transformed, favoring, context);
}
Also used : Goal(baritone.api.pathing.goals.Goal) GoalXZ(baritone.api.pathing.goals.GoalXZ) Favoring(baritone.utils.pathing.Favoring) IGoalRenderPos(baritone.api.utils.interfaces.IGoalRenderPos) BlockPos(net.minecraft.util.math.BlockPos) BetterBlockPos(baritone.api.utils.BetterBlockPos) AStarPathFinder(baritone.pathing.calc.AStarPathFinder)

Example 3 with IGoalRenderPos

use of baritone.api.utils.interfaces.IGoalRenderPos in project baritone by cabaletta.

the class PathRenderer method drawDankLitGoalBox.

public static void drawDankLitGoalBox(Entity player, Goal goal, float partialTicks, Color color) {
    double renderPosX = renderManager.viewerPosX;
    double renderPosY = renderManager.viewerPosY;
    double renderPosZ = renderManager.viewerPosZ;
    double minX, maxX;
    double minZ, maxZ;
    double minY, maxY;
    double y, y1, y2;
    if (!settings.renderGoalAnimated.value) {
        // y = 1 causes rendering issues when the player is at the same y as the top of a block for some reason
        y = 0.999F;
    } else {
        y = MathHelper.cos((float) (((float) ((System.nanoTime() / 100000L) % 20000L)) / 20000F * Math.PI * 2));
    }
    if (goal instanceof IGoalRenderPos) {
        BlockPos goalPos = ((IGoalRenderPos) goal).getGoalPos();
        minX = goalPos.getX() + 0.002 - renderPosX;
        maxX = goalPos.getX() + 1 - 0.002 - renderPosX;
        minZ = goalPos.getZ() + 0.002 - renderPosZ;
        maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ;
        if (goal instanceof GoalGetToBlock || goal instanceof GoalTwoBlocks) {
            y /= 2;
        }
        y1 = 1 + y + goalPos.getY() - renderPosY;
        y2 = 1 - y + goalPos.getY() - renderPosY;
        minY = goalPos.getY() - renderPosY;
        maxY = minY + 2;
        if (goal instanceof GoalGetToBlock || goal instanceof GoalTwoBlocks) {
            y1 -= 0.5;
            y2 -= 0.5;
            maxY--;
        }
    } else if (goal instanceof GoalXZ) {
        GoalXZ goalPos = (GoalXZ) goal;
        if (settings.renderGoalXZBeacon.value) {
            glPushAttrib(GL_LIGHTING_BIT);
            Helper.mc.getTextureManager().bindTexture(TileEntityBeaconRenderer.TEXTURE_BEACON_BEAM);
            if (settings.renderGoalIgnoreDepth.value) {
                GlStateManager.disableDepth();
            }
            TileEntityBeaconRenderer.renderBeamSegment(goalPos.getX() - renderPosX, -renderPosY, goalPos.getZ() - renderPosZ, settings.renderGoalAnimated.value ? partialTicks : 0, 1.0, settings.renderGoalAnimated.value ? player.world.getTotalWorldTime() : 0, 0, 256, color.getColorComponents(null));
            if (settings.renderGoalIgnoreDepth.value) {
                GlStateManager.enableDepth();
            }
            glPopAttrib();
            return;
        }
        minX = goalPos.getX() + 0.002 - renderPosX;
        maxX = goalPos.getX() + 1 - 0.002 - renderPosX;
        minZ = goalPos.getZ() + 0.002 - renderPosZ;
        maxZ = goalPos.getZ() + 1 - 0.002 - renderPosZ;
        y1 = 0;
        y2 = 0;
        minY = 0 - renderPosY;
        maxY = 256 - renderPosY;
    } else if (goal instanceof GoalComposite) {
        for (Goal g : ((GoalComposite) goal).goals()) {
            drawDankLitGoalBox(player, g, partialTicks, color);
        }
        return;
    } else if (goal instanceof GoalInverted) {
        drawDankLitGoalBox(player, ((GoalInverted) goal).origin, partialTicks, settings.colorInvertedGoalBox.value);
        return;
    } else if (goal instanceof GoalYLevel) {
        GoalYLevel goalpos = (GoalYLevel) goal;
        minX = player.posX - settings.yLevelBoxSize.value - renderPosX;
        minZ = player.posZ - settings.yLevelBoxSize.value - renderPosZ;
        maxX = player.posX + settings.yLevelBoxSize.value - renderPosX;
        maxZ = player.posZ + settings.yLevelBoxSize.value - renderPosZ;
        minY = ((GoalYLevel) goal).level - renderPosY;
        maxY = minY + 2;
        y1 = 1 + y + goalpos.level - renderPosY;
        y2 = 1 - y + goalpos.level - renderPosY;
    } else {
        return;
    }
    IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
    renderHorizontalQuad(minX, maxX, minZ, maxZ, y1);
    renderHorizontalQuad(minX, maxX, minZ, maxZ, y2);
    buffer.begin(GL_LINES, DefaultVertexFormats.POSITION);
    buffer.pos(minX, minY, minZ).endVertex();
    buffer.pos(minX, maxY, minZ).endVertex();
    buffer.pos(maxX, minY, minZ).endVertex();
    buffer.pos(maxX, maxY, minZ).endVertex();
    buffer.pos(maxX, minY, maxZ).endVertex();
    buffer.pos(maxX, maxY, maxZ).endVertex();
    buffer.pos(minX, minY, maxZ).endVertex();
    buffer.pos(minX, maxY, maxZ).endVertex();
    tessellator.draw();
    IRenderer.endLines(settings.renderGoalIgnoreDepth.value);
}
Also used : IGoalRenderPos(baritone.api.utils.interfaces.IGoalRenderPos) BlockPos(net.minecraft.util.math.BlockPos) BetterBlockPos(baritone.api.utils.BetterBlockPos)

Example 4 with IGoalRenderPos

use of baritone.api.utils.interfaces.IGoalRenderPos in project baritone by cabaletta.

the class PathingBehavior method createPathfinder.

private static AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal, IPath previous, CalculationContext context) {
    Goal transformed = goal;
    if (Baritone.settings().simplifyUnloadedYCoord.value && goal instanceof IGoalRenderPos) {
        BlockPos pos = ((IGoalRenderPos) goal).getGoalPos();
        if (!context.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ())) {
            transformed = new GoalXZ(pos.getX(), pos.getZ());
        }
    }
    Favoring favoring = new Favoring(context.getBaritone().getPlayerContext(), previous, context);
    return new AStarPathFinder(start.getX(), start.getY(), start.getZ(), transformed, favoring, context);
}
Also used : Goal(baritone.api.pathing.goals.Goal) GoalXZ(baritone.api.pathing.goals.GoalXZ) Favoring(baritone.utils.pathing.Favoring) IGoalRenderPos(baritone.api.utils.interfaces.IGoalRenderPos) BlockPos(net.minecraft.util.math.BlockPos) BetterBlockPos(baritone.api.utils.BetterBlockPos) AStarPathFinder(baritone.pathing.calc.AStarPathFinder)

Aggregations

BetterBlockPos (baritone.api.utils.BetterBlockPos)4 IGoalRenderPos (baritone.api.utils.interfaces.IGoalRenderPos)4 BlockPos (net.minecraft.util.math.BlockPos)4 Goal (baritone.api.pathing.goals.Goal)2 GoalXZ (baritone.api.pathing.goals.GoalXZ)2 AStarPathFinder (baritone.pathing.calc.AStarPathFinder)2 Favoring (baritone.utils.pathing.Favoring)2