1
0
mirror of https://github.com/cabaletta/baritone synced 2024-12-26 00:42:26 +00:00

add defaults to switches

This commit is contained in:
Leijurv 2018-09-16 19:50:07 -07:00
parent f25f264fd3
commit 3011b85aee
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
5 changed files with 34 additions and 35 deletions

View File

@ -19,9 +19,9 @@ package baritone.behavior;
import baritone.Baritone;
import baritone.Settings;
import baritone.api.behavior.Behavior;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.RotationMoveEvent;
import baritone.api.behavior.Behavior;
import baritone.utils.Helper;
import baritone.utils.Rotation;
@ -89,6 +89,8 @@ public final class LookBehavior extends Behavior implements Helper {
}
break;
}
default:
break;
}
}

View File

@ -17,10 +17,10 @@
package baritone.behavior;
import baritone.api.behavior.Behavior;
import baritone.api.event.events.PacketEvent;
import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.type.EventState;
import baritone.api.behavior.Behavior;
import baritone.utils.Helper;
import net.minecraft.item.ItemStack;
import net.minecraft.network.Packet;
@ -94,31 +94,28 @@ public final class MemoryBehavior extends Behavior implements Helper {
public void onReceivePacket(PacketEvent event) {
Packet p = event.getPacket();
switch (event.getState()) {
case PRE: {
if (p instanceof SPacketOpenWindow) {
SPacketOpenWindow packet = event.cast();
if (event.getState() == EventState.PRE) {
if (p instanceof SPacketOpenWindow) {
SPacketOpenWindow packet = event.cast();
// Remove any entries that were created over a second ago, this should make up for INSANE latency
this.futureInventories.removeIf(i -> System.nanoTime() / 1000000L - i.time > 1000);
// Remove any entries that were created over a second ago, this should make up for INSANE latency
this.futureInventories.removeIf(i -> System.nanoTime() / 1000000L - i.time > 1000);
this.futureInventories.stream()
.filter(i -> i.type.equals(packet.getGuiId()) && i.slots == packet.getSlotCount())
.findFirst().ifPresent(matched -> {
// Remove the future inventory
this.futureInventories.remove(matched);
this.futureInventories.stream()
.filter(i -> i.type.equals(packet.getGuiId()) && i.slots == packet.getSlotCount())
.findFirst().ifPresent(matched -> {
// Remove the future inventory
this.futureInventories.remove(matched);
// Setup the remembered inventory
RememberedInventory inventory = this.rememberedInventories.computeIfAbsent(matched.pos, pos -> new RememberedInventory());
inventory.windowId = packet.getWindowId();
inventory.size = packet.getSlotCount();
});
}
// Setup the remembered inventory
RememberedInventory inventory = this.rememberedInventories.computeIfAbsent(matched.pos, pos -> new RememberedInventory());
inventory.windowId = packet.getWindowId();
inventory.size = packet.getSlotCount();
});
}
if (p instanceof SPacketCloseWindow) {
updateInventory();
}
break;
if (p instanceof SPacketCloseWindow) {
updateInventory();
}
}
}

View File

@ -26,7 +26,8 @@ import baritone.api.event.events.TickEvent;
import baritone.pathing.calc.AStarPathFinder;
import baritone.pathing.calc.AbstractNodeCostSearch;
import baritone.pathing.calc.IPathFinder;
import baritone.pathing.goals.*;
import baritone.pathing.goals.Goal;
import baritone.pathing.goals.GoalXZ;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.path.IPath;
import baritone.pathing.path.PathExecutor;
@ -163,6 +164,8 @@ public final class PathingBehavior extends Behavior implements Helper {
case POST:
mc.gameSettings.autoJump = lastAutoJump;
break;
default:
break;
}
}
}

View File

@ -21,11 +21,11 @@ import baritone.Baritone;
import baritone.api.event.events.*;
import baritone.api.event.events.type.EventState;
import baritone.api.event.listener.IGameEventListener;
import baritone.api.utils.interfaces.Toggleable;
import baritone.cache.WorldProvider;
import baritone.utils.BlockStateInterface;
import baritone.utils.Helper;
import baritone.utils.InputOverrideHandler;
import baritone.api.utils.interfaces.Toggleable;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.world.chunk.Chunk;
import org.lwjgl.input.Keyboard;
@ -136,15 +136,11 @@ public final class GameEventHandler implements IGameEventListener, Helper {
BlockStateInterface.clearCachedChunk();
switch (event.getState()) {
case PRE:
break;
case POST:
cache.closeWorld();
if (event.getWorld() != null) {
cache.initWorld(event.getWorld());
}
break;
if (event.getState() == EventState.POST) {
cache.closeWorld();
if (event.getWorld() != null) {
cache.initWorld(event.getWorld());
}
}
listeners.forEach(l -> {

View File

@ -130,8 +130,9 @@ public class MovementParkour extends Movement {
return WALK_ONE_BLOCK_COST * 3;
case 4:
return SPRINT_ONE_BLOCK_COST * 4;
default:
throw new IllegalStateException("LOL");
}
throw new IllegalStateException("LOL");
}