dank goal render

This commit is contained in:
Leijurv 2018-08-15 17:53:42 -07:00
parent 6be7786707
commit 6860521403
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
3 changed files with 75 additions and 18 deletions

View File

@ -45,6 +45,7 @@ public class Settings {
Item.getItemFromBlock(Blocks.COBBLESTONE),
Item.getItemFromBlock(Blocks.NETHERRACK)
));
public Setting<Boolean> renderGoal = new Setting<>(true);
public final Map<String, Setting<?>> byName;
public final List<Setting<?>> allSettings;

View File

@ -25,6 +25,7 @@ import baritone.bot.pathing.calc.AStarPathFinder;
import baritone.bot.pathing.calc.AbstractNodeCostSearch;
import baritone.bot.pathing.calc.IPathFinder;
import baritone.bot.pathing.goals.Goal;
import baritone.bot.pathing.goals.GoalBlock;
import baritone.bot.pathing.path.IPath;
import baritone.bot.pathing.path.PathExecutor;
import baritone.bot.utils.PathRenderer;
@ -198,19 +199,13 @@ public class PathingBehavior extends Behavior {
}
}
});
/*
isThereAnythingInProgress = false;
if (!currentPath.goal.isInGoal(currentPath.end)) {
if (talkAboutIt) {
Out.gui("I couldn't get all the way to " + goal + ", but I'm going to get as close as I can. " + currentPath.numNodes + " nodes considered", Out.Mode.Standard);
}
planAhead();
} else if (talkAboutIt) {
Out.gui(, Out.Mode.Debug);
}
*/
if (talkAboutIt && current != null && current.getPath() != null) {
displayChatMessageRaw("Finished finding a path from " + start + " towards " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
if (goal.isInGoal(current.getPath().getDest())) {
displayChatMessageRaw("Finished finding a path from " + start + " to " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
} else {
displayChatMessageRaw("Found path segment from " + start + " towards " + goal + ". " + current.getPath().getNumNodesConsidered() + " nodes considered");
}
}
synchronized (pathCalcLock) {
isPathCalcInProgress = false;
@ -240,14 +235,19 @@ public class PathingBehavior extends Behavior {
@Override
public void onRenderPass(RenderEvent event) {
if (!Baritone.settings().renderPath.get()) {
return;
}
// System.out.println("Render passing");
// System.out.println(event.getPartialTicks());
float partialTicks = event.getPartialTicks();
if (goal instanceof GoalBlock && Baritone.settings().renderGoal.value) {
PathRenderer.drawLitDankGoalBox(player(), ((GoalBlock) goal).getGoalPos(), partialTicks, Color.GREEN);
}
if (!Baritone.settings().renderPath.get()) {
return;
}
long start = System.nanoTime();
PathExecutor current = this.current; // this should prevent most race conditions?
PathExecutor next = this.next; // like, now it's not possible for current!=null to be true, then suddenly false because of another thread
// TODO is this enough, or do we need to acquire a lock here?

View File

@ -58,8 +58,8 @@ public final class PathRenderer implements Helper {
List<BlockPos> positions = path.positions();
int next;
Tessellator tessellator = Tessellator.getInstance();
fadeStart+=startIndex;
fadeEnd+=startIndex;
fadeStart += startIndex;
fadeEnd += startIndex;
for (int i = startIndex; i < positions.size() - 1; i = next) {
BlockPos start = positions.get(i);
@ -86,7 +86,7 @@ public final class PathRenderer implements Helper {
if (i > fadeEnd) {
break;
}
alpha = 0.4F * (1.0F - (float)(i - fadeStart) / (float)(fadeEnd - fadeStart));
alpha = 0.4F * (1.0F - (float) (i - fadeStart) / (float) (fadeEnd - fadeStart));
}
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], alpha);
}
@ -159,6 +159,62 @@ public final class PathRenderer implements Helper {
TESSELLATOR.draw();
});
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
public static void drawLitDankGoalBox(EntityPlayer player, BlockPos goal, float partialTicks, Color color) {
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.6F);
GlStateManager.glLineWidth(5.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
float expand = 0.002F;
double renderPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks;
double renderPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
double renderPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;
double minX = goal.getX() + 0.002 - renderPosX;
double maxX = goal.getX() + 1 - 0.002 - renderPosX;
double minZ = goal.getZ() + 0.002 - renderPosZ;
double maxZ = goal.getZ() + 1 - 0.002 - renderPosZ;
double y = Math.sin((System.currentTimeMillis() % 2000L) / 2000F * Math.PI * 2);
double y1 = 1 + y + goal.getY() - renderPosY;
double y2 = 1 - y + goal.getY() - renderPosY;
double minY = goal.getY() - renderPosY;
double maxY = minY + 2;
BUFFER.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION);
BUFFER.pos(minX, y1, minZ).endVertex();
BUFFER.pos(maxX, y1, minZ).endVertex();
BUFFER.pos(maxX, y1, maxZ).endVertex();
BUFFER.pos(minX, y1, maxZ).endVertex();
BUFFER.pos(minX, y1, minZ).endVertex();
TESSELLATOR.draw();
BUFFER.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION);
BUFFER.pos(minX, y2, minZ).endVertex();
BUFFER.pos(maxX, y2, minZ).endVertex();
BUFFER.pos(maxX, y2, maxZ).endVertex();
BUFFER.pos(minX, y2, maxZ).endVertex();
BUFFER.pos(minX, y2, minZ).endVertex();
TESSELLATOR.draw();
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();
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();