diff --git a/fabric/build.gradle b/fabric/build.gradle index 8adf7571b..c88ff80ef 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -26,6 +26,9 @@ archivesBaseName = archivesBaseName + "-fabric" minecraft { fabric() + runs.client = { + jvmArgs.add("-XstartOnFirstThread") + } } configurations { diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index 2ff732675..e694a8ee0 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -82,9 +82,12 @@ public final class LookBehavior extends Behavior implements ILookBehavior { @Override public void onPlayerUpdate(PlayerUpdateEvent event) { + System.out.println(event.getState() + " " + ctx.player().getXRot() + " " + ctx.player().getYRot() + " " + ctx.player().xRotO + " " + ctx.player().yRotO); + if (this.target == null) { return; } + switch (event.getState()) { case PRE: { if (this.target.mode == Target.Mode.NONE) { @@ -92,7 +95,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior { return; } - this.prevRotation = new Rotation(ctx.player().getXRot(), ctx.player().getYRot()); + this.prevRotation = new Rotation(ctx.player().getYRot(), ctx.player().getXRot()); final Rotation actual = this.processor.peekRotation(this.target.rotation); ctx.player().setYRot(actual.getYaw()); ctx.player().setXRot(actual.getPitch()); @@ -110,14 +113,16 @@ public final class LookBehavior extends Behavior implements ILookBehavior { this.smoothPitchBuffer.removeFirst(); } if (this.target.mode == Target.Mode.SERVER) { - ctx.player().setXRot(this.prevRotation.getYaw()); - ctx.player().setYRot(this.prevRotation.getPitch()); + ctx.player().setYRot(this.prevRotation.getYaw()); + ctx.player().setXRot(this.prevRotation.getPitch()); } else if (ctx.player().isFallFlying() ? Baritone.settings().elytraSmoothLook.value : Baritone.settings().smoothLook.value) { - ctx.player().setXRot((float) this.smoothYawBuffer.stream().mapToDouble(d -> d).average().orElse(this.prevRotation.getYaw())); + ctx.player().setYRot((float) this.smoothYawBuffer.stream().mapToDouble(d -> d).average().orElse(this.prevRotation.getYaw())); if (ctx.player().isFallFlying()) { - ctx.player().setYRot((float) this.smoothPitchBuffer.stream().mapToDouble(d -> d).average().orElse(this.prevRotation.getPitch())); + ctx.player().setXRot((float) this.smoothPitchBuffer.stream().mapToDouble(d -> d).average().orElse(this.prevRotation.getPitch())); } } + //ctx.player().xRotO = prevRotation.getPitch(); + //ctx.player().yRotO = prevRotation.getYaw(); this.prevRotation = null; } // The target is done being used for this game tick, so it can be invalidated diff --git a/src/main/java/baritone/process/ElytraProcess.java b/src/main/java/baritone/process/ElytraProcess.java index 7ede8543f..e0b6a1a03 100644 --- a/src/main/java/baritone/process/ElytraProcess.java +++ b/src/main/java/baritone/process/ElytraProcess.java @@ -364,7 +364,8 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro // elytrabehavior replaces when durability <= minimumDurability, so if durability < minimumDurability then we can reasonably assume that the elytra will soon be broken without replacement return true; } - NonNullList inv = ctx.player().inventoryMenu.getItems(); + + NonNullList inv = ctx.player().getInventory().items; int qty = 0; for (int i = 0; i < 36; i++) { if (ElytraBehavior.isFireworks(inv.get(i))) { @@ -404,6 +405,8 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro @Override public void onRenderPass(RenderEvent event) { + System.out.println(event.getPartialTicks() + " " + ctx.player().getXRot() + " " + ctx.player().getYRot() + " " + ctx.player().xRotO + " " + ctx.player().yRotO); + if (this.behavior != null) this.behavior.onRenderPass(event); } diff --git a/src/main/java/baritone/process/elytra/ElytraBehavior.java b/src/main/java/baritone/process/elytra/ElytraBehavior.java index 82225456e..2ba8744fb 100644 --- a/src/main/java/baritone/process/elytra/ElytraBehavior.java +++ b/src/main/java/baritone/process/elytra/ElytraBehavior.java @@ -402,6 +402,7 @@ public final class ElytraBehavior implements Helper { } public void onRenderPass(RenderEvent event) { + final Settings settings = Baritone.settings(); if (this.visiblePath != null) { PathRenderer.drawPath(event.getModelViewStack(), this.visiblePath, 0, Color.RED, false, 0, 0, 0.0D); @@ -412,14 +413,14 @@ public final class ElytraBehavior implements Helper { if (!this.clearLines.isEmpty() && settings.elytraRenderRaytraces.value) { IRenderer.startLines(Color.GREEN, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value); for (Pair line : this.clearLines) { - IRenderer.emitLine(line.first(), line.second()); + IRenderer.emitLine(event.getModelViewStack(), line.first(), line.second()); } IRenderer.endLines(settings.renderPathIgnoreDepth.value); } if (!this.blockedLines.isEmpty() && Baritone.settings().elytraRenderRaytraces.value) { IRenderer.startLines(Color.BLUE, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value); for (Pair line : this.blockedLines) { - IRenderer.emitLine(line.first(), line.second()); + IRenderer.emitLine(event.getModelViewStack(), line.first(), line.second()); } IRenderer.endLines(settings.renderPathIgnoreDepth.value); } @@ -429,7 +430,7 @@ public final class ElytraBehavior implements Helper { for (int i = 0; i < this.simulationLine.size() - 1; i++) { final Vec3 src = this.simulationLine.get(i).add(offset); final Vec3 dst = this.simulationLine.get(i + 1).add(offset); - IRenderer.emitLine(src, dst); + IRenderer.emitLine(event.getModelViewStack(), src, dst); } IRenderer.endLines(settings.renderPathIgnoreDepth.value); } @@ -1272,7 +1273,7 @@ public final class ElytraBehavior implements Helper { } private int findGoodElytra() { - NonNullList invy = ctx.player().inventoryMenu.getItems(); + NonNullList invy = ctx.player().getInventory().items; for (int i = 0; i < invy.size(); i++) { ItemStack slot = invy.get(i); if (slot.getItem() == Items.ELYTRA && (slot.getItem().getMaxDamage() - slot.getDamageValue()) > Baritone.settings().elytraMinimumDurability.value) { diff --git a/src/main/java/baritone/process/elytra/NetherPathfinderContext.java b/src/main/java/baritone/process/elytra/NetherPathfinderContext.java index 47ecdca96..de666a0a8 100644 --- a/src/main/java/baritone/process/elytra/NetherPathfinderContext.java +++ b/src/main/java/baritone/process/elytra/NetherPathfinderContext.java @@ -201,23 +201,15 @@ public final class NetherPathfinderContext { long maxEntryValue = (1L << bitsPerEntry) - 1L; final int yReal = y0 << 4; - for (int idx = 0, kl = bitsPerEntry - 1; idx < arraySize; idx++, kl += bitsPerEntry) { - final int i = idx * bitsPerEntry; - final int j = i >> 6; - final int l = i & 63; - final int k = kl >> 6; - final long jl = longArray[j] >>> l; - - final int id; - if (j == k) { - id = (int) (jl & maxEntryValue); - } else { - id = (int) ((jl | longArray[k] << (64 - l)) & maxEntryValue); + for (int i = 0, idx = 0; i < longArray.length && idx < arraySize; ++i) { + long l = longArray[i]; + for (int offset = 0; offset <= (64 - bitsPerEntry) && idx < arraySize; offset += bitsPerEntry, ++idx) { + int value = (int) ((l >> offset) & maxEntryValue); + int x = (idx & 15); + int y = yReal + (idx >> 8); + int z = ((idx >> 4) & 15); + Octree.setBlock(ptr, x, y, z, value != airId); } - int x = (idx & 15); - int y = yReal + (idx >> 8); - int z = ((idx >> 4) & 15); - Octree.setBlock(ptr, x, y, z, id != airId); } } Octree.setIsFromJava(ptr); diff --git a/src/main/java/baritone/utils/IRenderer.java b/src/main/java/baritone/utils/IRenderer.java index 0721019c6..7f6065b72 100644 --- a/src/main/java/baritone/utils/IRenderer.java +++ b/src/main/java/baritone/utils/IRenderer.java @@ -146,15 +146,11 @@ public interface IRenderer { emitAABB(stack, aabb.inflate(expand, expand, expand)); } - static void emitLine(Vec3 start, Vec3 end) { - emitLine(start.x, start.y, start.z, end.x, end.y, end.z); - } - - static void emitLine(double x1, double y1, double z1, double x2, double y2, double z2) { + static void emitLine(PoseStack stack, Vec3 start, Vec3 end) { double vpX = renderManager.renderPosX(); double vpY = renderManager.renderPosY(); double vpZ = renderManager.renderPosZ(); - buffer.vertex(x1 - vpX, y1 - vpY, z1 - vpZ).color(color[0], color[1], color[2], color[3]).endVertex(); - buffer.vertex(x2 - vpX, y2 - vpY, z2 - vpZ).color(color[0], color[1], color[2], color[3]).endVertex(); + emitLine(stack, start.x - vpX, start.y - vpY, start.z - vpZ, end.x - vpX, end.y - vpY, end.z - vpZ); } + }