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

Method render

src/main/java/baritone/utils/PathRenderer.java:67–126  ·  view source on GitHub ↗
(RenderEvent event, PathingBehavior behavior)

Source from the content-addressed store, hash-verified

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);
109 }
110
111 if (next != null && next.getPath() != null) {
112 drawPath(event.getModelViewStack(), next.getPath().positions(), 0, settings.colorNextPath.value, settings.fadePath.value, 10, 20);
113 }
114
115 // If there is a path calculation currently running, render the path calculation process
116 behavior.getInProgress().ifPresent(currentlyRunning -> {
117 currentlyRunning.bestPathSoFar().ifPresent(p -> {
118 drawPath(event.getModelViewStack(), p.positions(), 0, settings.colorBestPathSoFar.value, settings.fadePath.value, 10, 20);
119 });
120
121 currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> {
122 drawPath(event.getModelViewStack(), mr.positions(), 0, settings.colorMostRecentConsidered.value, settings.fadePath.value, 10, 20);
123 drawManySelectionBoxes(event.getModelViewStack(), ctx.player(), Collections.singletonList(mr.getDest()), settings.colorMostRecentConsidered.value);
124 });

Callers 1

onRenderPassMethod · 0.95

Calls 15

worldMethod · 0.95
minecraftMethod · 0.95
getProviderMethod · 0.95
drawGoalMethod · 0.95
playerMethod · 0.95
toBreakMethod · 0.95
toPlaceMethod · 0.95
toWalkIntoMethod · 0.95
getPathMethod · 0.95
getPositionMethod · 0.95
drawPathMethod · 0.95

Tested by

no test coverage detected