render the same movement many times in a row as just one longer line

This commit is contained in:
Leijurv 2018-08-09 13:03:07 -07:00
parent a1dc98589c
commit 28ee485a87
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -205,6 +205,10 @@ public class PathingBehavior extends Behavior {
// System.out.println("Frame took " + (split - start) + " " + (end - split)); // System.out.println("Frame took " + (split - start) + " " + (end - split));
} }
private static BlockPos diff(BlockPos a, BlockPos b) {
return new BlockPos(a.getX() - b.getX(), a.getY() - b.getY(), a.getZ() - b.getZ());
}
public void drawPath(IPath path, EntityPlayerSP player, float partialTicks, Color color) { public void drawPath(IPath path, EntityPlayerSP player, float partialTicks, Color color) {
GlStateManager.enableBlend(); GlStateManager.enableBlend();
@ -216,15 +220,23 @@ public class PathingBehavior extends Behavior {
List<BlockPos> positions = path.positions(); List<BlockPos> positions = path.positions();
for (int i = 0; i < positions.size() - 1; i++) { int next;
BlockPos a = positions.get(i); for (int i = 0; i < positions.size() - 1; i = next) {
BlockPos b = positions.get(i + 1); BlockPos start = positions.get(i);
double x1 = a.getX();
double y1 = a.getY(); next = i + 1;
double z1 = a.getZ(); BlockPos end = positions.get(next);
double x2 = b.getX(); BlockPos direction = diff(start, end);
double y2 = b.getY(); while (next + 1 < positions.size() && direction.equals(diff(end, positions.get(next + 1)))) {
double z2 = b.getZ(); next++;
end = positions.get(next);
}
double x1 = start.getX();
double y1 = start.getY();
double z1 = start.getZ();
double x2 = end.getX();
double y2 = end.getY();
double z2 = end.getZ();
drawLine(player, x1, y1, z1, x2, y2, z2, partialTicks); drawLine(player, x1, y1, z1, x2, y2, z2, partialTicks);
} }
//GlStateManager.color(0.0f, 0.0f, 0.0f, 0.4f); //GlStateManager.color(0.0f, 0.0f, 0.0f, 0.4f);