MCPcopy Create free account
hub / github.com/cabaletta/baritone / PathRenderer

Class PathRenderer

src/main/java/baritone/utils/PathRenderer.java:51–362  ·  view source on GitHub ↗

@author Brady @since 8/9/2018

Source from the content-addressed store, hash-verified

49 * @since 8/9/2018
50 */
51public final class PathRenderer implements IRenderer {
52
53 private PathRenderer() {}
54
55 public static double posX() {
56 return renderManager.renderPosX();
57 }
58
59 public static double posY() {
60 return renderManager.renderPosY();
61 }
62
63 public static double posZ() {
64 return renderManager.renderPosZ();
65 }
66
67 public static void render(RenderEvent event, PathingBehavior behavior) {
68 final IPlayerContext ctx = behavior.ctx;
69 if (ctx.world() == null) {
70 return;
71 }
72 if (ctx.minecraft().screen instanceof GuiClick) {
73 ((GuiClick) ctx.minecraft().screen).onRender(event.getModelViewStack(), event.getProjectionMatrix());
74 }
75
76 final float partialTicks = event.getPartialTicks();
77 final Goal goal = behavior.getGoal();
78
79 final DimensionType thisPlayerDimension = ctx.world().dimensionType();
80 final DimensionType currentRenderViewDimension = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().dimensionType();
81
82 if (thisPlayerDimension != currentRenderViewDimension) {
83 // this is a path for a bot in a different dimension, don't render it
84 return;
85 }
86
87 if (goal != null && settings.renderGoal.value) {
88 drawGoal(event.getModelViewStack(), ctx, goal, partialTicks, settings.colorGoalBox.value);
89 }
90
91 if (!settings.renderPath.value) {
92 return;
93 }
94
95 PathExecutor current = behavior.getCurrent(); // this should prevent most race conditions?
96 PathExecutor next = behavior.getNext(); // like, now it's not possible for current!=null to be true, then suddenly false because of another thread
97 if (current != null && settings.renderSelectionBoxes.value) {
98 drawManySelectionBoxes(event.getModelViewStack(), ctx.player(), current.toBreak(), settings.colorBlocksToBreak.value);
99 drawManySelectionBoxes(event.getModelViewStack(), ctx.player(), current.toPlace(), settings.colorBlocksToPlace.value);
100 drawManySelectionBoxes(event.getModelViewStack(), ctx.player(), current.toWalkInto(), settings.colorBlocksToWalkInto.value);
101 }
102
103 //drawManySelectionBoxes(player, Collections.singletonList(behavior.pathStart()), partialTicks, Color.WHITE);
104
105 // Render the current path, if there is one
106 if (current != null && current.getPath() != null) {
107 int renderBegin = Math.max(current.getPosition() - 3, 0);
108 drawPath(event.getModelViewStack(), current.getPath().positions(), renderBegin, settings.colorCurrentPath.value, settings.fadePath.value, 10, 20);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected