Merge branch 'master' into builder

This commit is contained in:
Leijurv 2019-02-06 21:05:14 -08:00
commit 68e8717b5c
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
5 changed files with 42 additions and 3 deletions

View File

@ -378,6 +378,13 @@ public final class Settings {
*/ */
public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(false); public final Setting<Boolean> pruneRegionsFromRAM = new Setting<>(false);
/**
* Remember the contents of containers (chests, echests, furnaces)
* <p>
* Really buggy since the packet stuff is multithreaded badly thanks to brady
*/
public final Setting<Boolean> containerMemory = new Setting<>(false);
/** /**
* Print all the debug messages to chat * Print all the debug messages to chat
*/ */

View File

@ -65,6 +65,9 @@ public final class MemoryBehavior extends Behavior {
@Override @Override
public synchronized void onTick(TickEvent event) { public synchronized void onTick(TickEvent event) {
if (!Baritone.settings().containerMemory.get()) {
return;
}
if (event.getType() == TickEvent.Type.OUT) { if (event.getType() == TickEvent.Type.OUT) {
enderChestWindowId = null; enderChestWindowId = null;
futureInventories.clear(); futureInventories.clear();
@ -80,6 +83,9 @@ public final class MemoryBehavior extends Behavior {
@Override @Override
public synchronized void onSendPacket(PacketEvent event) { public synchronized void onSendPacket(PacketEvent event) {
if (!Baritone.settings().containerMemory.get()) {
return;
}
Packet p = event.getPacket(); Packet p = event.getPacket();
if (event.getState() == EventState.PRE) { if (event.getState() == EventState.PRE) {
@ -116,6 +122,9 @@ public final class MemoryBehavior extends Behavior {
@Override @Override
public synchronized void onReceivePacket(PacketEvent event) { public synchronized void onReceivePacket(PacketEvent event) {
if (!Baritone.settings().containerMemory.get()) {
return;
}
Packet p = event.getPacket(); Packet p = event.getPacket();
if (event.getState() == EventState.PRE) { if (event.getState() == EventState.PRE) {
@ -162,6 +171,9 @@ public final class MemoryBehavior extends Behavior {
private void updateInventory() { private void updateInventory() {
if (!Baritone.settings().containerMemory.get()) {
return;
}
int windowId = ctx.player().openContainer.windowId; int windowId = ctx.player().openContainer.windowId;
if (enderChestWindowId != null) { if (enderChestWindowId != null) {
if (windowId == enderChestWindowId) { if (windowId == enderChestWindowId) {

View File

@ -17,6 +17,7 @@
package baritone.cache; package baritone.cache;
import baritone.Baritone;
import baritone.api.cache.IContainerMemory; import baritone.api.cache.IContainerMemory;
import baritone.api.cache.IRememberedInventory; import baritone.api.cache.IRememberedInventory;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
@ -69,6 +70,9 @@ public class ContainerMemory implements IContainerMemory {
} }
public synchronized void save() throws IOException { public synchronized void save() throws IOException {
if (!Baritone.settings().containerMemory.get()) {
return;
}
ByteBuf buf = Unpooled.buffer(0, Integer.MAX_VALUE); ByteBuf buf = Unpooled.buffer(0, Integer.MAX_VALUE);
PacketBuffer out = new PacketBuffer(buf); PacketBuffer out = new PacketBuffer(buf);
out.writeInt(inventories.size()); out.writeInt(inventories.size());

View File

@ -210,8 +210,8 @@ public class MovementDescend extends Movement {
}*/ }*/
} }
if (safeMode()) { if (safeMode()) {
double destX = (src.getX() + 0.5) * 0.19 + (dest.getX() + 0.5) * 0.81; double destX = (src.getX() + 0.5) * 0.17 + (dest.getX() + 0.5) * 0.83;
double destZ = (src.getZ() + 0.5) * 0.19 + (dest.getZ() + 0.5) * 0.81; double destZ = (src.getZ() + 0.5) * 0.17 + (dest.getZ() + 0.5) * 0.83;
EntityPlayerSP player = ctx.player(); EntityPlayerSP player = ctx.player();
state.setTarget(new MovementState.MovementTarget( state.setTarget(new MovementState.MovementTarget(
new Rotation(RotationUtils.calcRotationFromVec3d(player.getPositionEyes(1.0F), new Rotation(RotationUtils.calcRotationFromVec3d(player.getPositionEyes(1.0F),
@ -245,6 +245,10 @@ public class MovementDescend extends Movement {
// (dest - src) + dest is offset 1 more in the same direction // (dest - src) + dest is offset 1 more in the same direction
// so it's the block we'd need to worry about running into if we decide to sprint straight through this descend // so it's the block we'd need to worry about running into if we decide to sprint straight through this descend
BlockPos into = dest.subtract(src.down()).add(dest); BlockPos into = dest.subtract(src.down()).add(dest);
if (!MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into)) && MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into).up()) && MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into).up(2))) {
// if dest extends into can't walk through, but the two above are can walk through, then we can overshoot and glitch in that weird way
return true;
}
for (int y = 0; y <= 2; y++) { // we could hit any of the three blocks for (int y = 0; y <= 2; y++) { // we could hit any of the three blocks
if (MovementHelper.avoidWalkingInto(BlockStateInterface.getBlock(ctx, into.up(y)))) { if (MovementHelper.avoidWalkingInto(BlockStateInterface.getBlock(ctx, into.up(y)))) {
return true; return true;

View File

@ -173,13 +173,25 @@ public class MovementDiagonal extends Movement {
state.setStatus(MovementStatus.SUCCESS); state.setStatus(MovementStatus.SUCCESS);
return state; return state;
} }
if (!MovementHelper.isLiquid(ctx, ctx.playerFeet())) { if (sprint()) {
state.setInput(Input.SPRINT, true); state.setInput(Input.SPRINT, true);
} }
MovementHelper.moveTowards(ctx, state, dest); MovementHelper.moveTowards(ctx, state, dest);
return state; return state;
} }
public boolean sprint() {
if (MovementHelper.isLiquid(ctx, ctx.playerFeet())) {
return false;
}
for (int i = 0; i < 4; i++) {
if (!MovementHelper.canWalkThrough(ctx, positionsToBreak[i])) {
return false;
}
}
return true;
}
@Override @Override
protected boolean prepared(MovementState state) { protected boolean prepared(MovementState state) {
return true; return true;