mostly works

This commit is contained in:
Leijurv 2023-08-17 20:03:44 -07:00
parent fd8ca8576b
commit bfc813a802
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
6 changed files with 33 additions and 33 deletions

View File

@ -26,6 +26,9 @@ archivesBaseName = archivesBaseName + "-fabric"
minecraft { minecraft {
fabric() fabric()
runs.client = {
jvmArgs.add("-XstartOnFirstThread")
}
} }
configurations { configurations {

View File

@ -82,9 +82,12 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
@Override @Override
public void onPlayerUpdate(PlayerUpdateEvent event) { 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) { if (this.target == null) {
return; return;
} }
switch (event.getState()) { switch (event.getState()) {
case PRE: { case PRE: {
if (this.target.mode == Target.Mode.NONE) { if (this.target.mode == Target.Mode.NONE) {
@ -92,7 +95,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
return; 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); final Rotation actual = this.processor.peekRotation(this.target.rotation);
ctx.player().setYRot(actual.getYaw()); ctx.player().setYRot(actual.getYaw());
ctx.player().setXRot(actual.getPitch()); ctx.player().setXRot(actual.getPitch());
@ -110,14 +113,16 @@ public final class LookBehavior extends Behavior implements ILookBehavior {
this.smoothPitchBuffer.removeFirst(); this.smoothPitchBuffer.removeFirst();
} }
if (this.target.mode == Target.Mode.SERVER) { if (this.target.mode == Target.Mode.SERVER) {
ctx.player().setXRot(this.prevRotation.getYaw()); ctx.player().setYRot(this.prevRotation.getYaw());
ctx.player().setYRot(this.prevRotation.getPitch()); ctx.player().setXRot(this.prevRotation.getPitch());
} else if (ctx.player().isFallFlying() ? Baritone.settings().elytraSmoothLook.value : Baritone.settings().smoothLook.value) { } 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()) { 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; this.prevRotation = null;
} }
// The target is done being used for this game tick, so it can be invalidated // The target is done being used for this game tick, so it can be invalidated

View File

@ -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 // 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; return true;
} }
NonNullList<ItemStack> inv = ctx.player().inventoryMenu.getItems();
NonNullList<ItemStack> inv = ctx.player().getInventory().items;
int qty = 0; int qty = 0;
for (int i = 0; i < 36; i++) { for (int i = 0; i < 36; i++) {
if (ElytraBehavior.isFireworks(inv.get(i))) { if (ElytraBehavior.isFireworks(inv.get(i))) {
@ -404,6 +405,8 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
@Override @Override
public void onRenderPass(RenderEvent event) { 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); if (this.behavior != null) this.behavior.onRenderPass(event);
} }

View File

@ -402,6 +402,7 @@ public final class ElytraBehavior implements Helper {
} }
public void onRenderPass(RenderEvent event) { public void onRenderPass(RenderEvent event) {
final Settings settings = Baritone.settings(); final Settings settings = Baritone.settings();
if (this.visiblePath != null) { if (this.visiblePath != null) {
PathRenderer.drawPath(event.getModelViewStack(), this.visiblePath, 0, Color.RED, false, 0, 0, 0.0D); 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) { if (!this.clearLines.isEmpty() && settings.elytraRenderRaytraces.value) {
IRenderer.startLines(Color.GREEN, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value); IRenderer.startLines(Color.GREEN, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
for (Pair<Vec3, Vec3> line : this.clearLines) { for (Pair<Vec3, Vec3> line : this.clearLines) {
IRenderer.emitLine(line.first(), line.second()); IRenderer.emitLine(event.getModelViewStack(), line.first(), line.second());
} }
IRenderer.endLines(settings.renderPathIgnoreDepth.value); IRenderer.endLines(settings.renderPathIgnoreDepth.value);
} }
if (!this.blockedLines.isEmpty() && Baritone.settings().elytraRenderRaytraces.value) { if (!this.blockedLines.isEmpty() && Baritone.settings().elytraRenderRaytraces.value) {
IRenderer.startLines(Color.BLUE, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value); IRenderer.startLines(Color.BLUE, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
for (Pair<Vec3, Vec3> line : this.blockedLines) { for (Pair<Vec3, Vec3> line : this.blockedLines) {
IRenderer.emitLine(line.first(), line.second()); IRenderer.emitLine(event.getModelViewStack(), line.first(), line.second());
} }
IRenderer.endLines(settings.renderPathIgnoreDepth.value); 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++) { for (int i = 0; i < this.simulationLine.size() - 1; i++) {
final Vec3 src = this.simulationLine.get(i).add(offset); final Vec3 src = this.simulationLine.get(i).add(offset);
final Vec3 dst = this.simulationLine.get(i + 1).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); IRenderer.endLines(settings.renderPathIgnoreDepth.value);
} }
@ -1272,7 +1273,7 @@ public final class ElytraBehavior implements Helper {
} }
private int findGoodElytra() { private int findGoodElytra() {
NonNullList<ItemStack> invy = ctx.player().inventoryMenu.getItems(); NonNullList<ItemStack> invy = ctx.player().getInventory().items;
for (int i = 0; i < invy.size(); i++) { for (int i = 0; i < invy.size(); i++) {
ItemStack slot = invy.get(i); ItemStack slot = invy.get(i);
if (slot.getItem() == Items.ELYTRA && (slot.getItem().getMaxDamage() - slot.getDamageValue()) > Baritone.settings().elytraMinimumDurability.value) { if (slot.getItem() == Items.ELYTRA && (slot.getItem().getMaxDamage() - slot.getDamageValue()) > Baritone.settings().elytraMinimumDurability.value) {

View File

@ -201,23 +201,15 @@ public final class NetherPathfinderContext {
long maxEntryValue = (1L << bitsPerEntry) - 1L; long maxEntryValue = (1L << bitsPerEntry) - 1L;
final int yReal = y0 << 4; final int yReal = y0 << 4;
for (int idx = 0, kl = bitsPerEntry - 1; idx < arraySize; idx++, kl += bitsPerEntry) { for (int i = 0, idx = 0; i < longArray.length && idx < arraySize; ++i) {
final int i = idx * bitsPerEntry; long l = longArray[i];
final int j = i >> 6; for (int offset = 0; offset <= (64 - bitsPerEntry) && idx < arraySize; offset += bitsPerEntry, ++idx) {
final int l = i & 63; int value = (int) ((l >> offset) & maxEntryValue);
final int k = kl >> 6; int x = (idx & 15);
final long jl = longArray[j] >>> l; int y = yReal + (idx >> 8);
int z = ((idx >> 4) & 15);
final int id; Octree.setBlock(ptr, x, y, z, value != airId);
if (j == k) {
id = (int) (jl & maxEntryValue);
} else {
id = (int) ((jl | longArray[k] << (64 - l)) & maxEntryValue);
} }
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); Octree.setIsFromJava(ptr);

View File

@ -146,15 +146,11 @@ public interface IRenderer {
emitAABB(stack, aabb.inflate(expand, expand, expand)); emitAABB(stack, aabb.inflate(expand, expand, expand));
} }
static void emitLine(Vec3 start, Vec3 end) { static void emitLine(PoseStack stack, 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) {
double vpX = renderManager.renderPosX(); double vpX = renderManager.renderPosX();
double vpY = renderManager.renderPosY(); double vpY = renderManager.renderPosY();
double vpZ = renderManager.renderPosZ(); double vpZ = renderManager.renderPosZ();
buffer.vertex(x1 - vpX, y1 - vpY, z1 - 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);
buffer.vertex(x2 - vpX, y2 - vpY, z2 - vpZ).color(color[0], color[1], color[2], color[3]).endVertex();
} }
} }