rearranged constructors
This commit is contained in:
parent
74dc8d4118
commit
a589cb0d9e
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
package baritone.behavior;
|
package baritone.behavior;
|
||||||
|
|
||||||
import baritone.api.event.events.TickEvent;
|
|
||||||
import baritone.api.behavior.Behavior;
|
import baritone.api.behavior.Behavior;
|
||||||
|
import baritone.api.event.events.TickEvent;
|
||||||
import baritone.pathing.goals.GoalNear;
|
import baritone.pathing.goals.GoalNear;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -32,11 +32,10 @@ public final class FollowBehavior extends Behavior {
|
|||||||
|
|
||||||
public static final FollowBehavior INSTANCE = new FollowBehavior();
|
public static final FollowBehavior INSTANCE = new FollowBehavior();
|
||||||
|
|
||||||
private FollowBehavior() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private Entity following;
|
private Entity following;
|
||||||
|
|
||||||
|
private FollowBehavior() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTick(TickEvent event) {
|
public void onTick(TickEvent event) {
|
||||||
if (event.getType() == TickEvent.Type.OUT) {
|
if (event.getType() == TickEvent.Type.OUT) {
|
||||||
|
@ -29,8 +29,6 @@ public final class LookBehavior extends Behavior implements Helper {
|
|||||||
|
|
||||||
public static final LookBehavior INSTANCE = new LookBehavior();
|
public static final LookBehavior INSTANCE = new LookBehavior();
|
||||||
|
|
||||||
private LookBehavior() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target's values are as follows:
|
* Target's values are as follows:
|
||||||
* <p>
|
* <p>
|
||||||
@ -51,6 +49,8 @@ public final class LookBehavior extends Behavior implements Helper {
|
|||||||
*/
|
*/
|
||||||
private float lastYaw;
|
private float lastYaw;
|
||||||
|
|
||||||
|
private LookBehavior() {}
|
||||||
|
|
||||||
public void updateTarget(Rotation target, boolean force) {
|
public void updateTarget(Rotation target, boolean force) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.force = force || !Baritone.settings().freeLook.get();
|
this.force = force || !Baritone.settings().freeLook.get();
|
||||||
|
@ -42,8 +42,6 @@ public final class MemoryBehavior extends Behavior implements Helper {
|
|||||||
|
|
||||||
public static MemoryBehavior INSTANCE = new MemoryBehavior();
|
public static MemoryBehavior INSTANCE = new MemoryBehavior();
|
||||||
|
|
||||||
private MemoryBehavior() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Possible future inventories that we will be able to remember
|
* Possible future inventories that we will be able to remember
|
||||||
*/
|
*/
|
||||||
@ -54,6 +52,8 @@ public final class MemoryBehavior extends Behavior implements Helper {
|
|||||||
*/
|
*/
|
||||||
private final Map<BlockPos, RememberedInventory> rememberedInventories = new HashMap<>();
|
private final Map<BlockPos, RememberedInventory> rememberedInventories = new HashMap<>();
|
||||||
|
|
||||||
|
private MemoryBehavior() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerUpdate(PlayerUpdateEvent event) {
|
public void onPlayerUpdate(PlayerUpdateEvent event) {
|
||||||
if (event.getState() == EventState.PRE) {
|
if (event.getState() == EventState.PRE) {
|
||||||
|
@ -49,12 +49,11 @@ public final class MineBehavior extends Behavior implements Helper {
|
|||||||
|
|
||||||
public static final MineBehavior INSTANCE = new MineBehavior();
|
public static final MineBehavior INSTANCE = new MineBehavior();
|
||||||
|
|
||||||
private MineBehavior() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Block> mining;
|
private List<Block> mining;
|
||||||
private List<BlockPos> locationsCache;
|
private List<BlockPos> locationsCache;
|
||||||
|
|
||||||
|
private MineBehavior() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTick(TickEvent event) {
|
public void onTick(TickEvent event) {
|
||||||
if (mining == null) {
|
if (mining == null) {
|
||||||
|
@ -47,9 +47,6 @@ public final class PathingBehavior extends Behavior implements Helper {
|
|||||||
|
|
||||||
public static final PathingBehavior INSTANCE = new PathingBehavior();
|
public static final PathingBehavior INSTANCE = new PathingBehavior();
|
||||||
|
|
||||||
private PathingBehavior() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private PathExecutor current;
|
private PathExecutor current;
|
||||||
private PathExecutor next;
|
private PathExecutor next;
|
||||||
|
|
||||||
@ -62,6 +59,8 @@ public final class PathingBehavior extends Behavior implements Helper {
|
|||||||
|
|
||||||
private boolean lastAutoJump;
|
private boolean lastAutoJump;
|
||||||
|
|
||||||
|
private PathingBehavior() {}
|
||||||
|
|
||||||
private void dispatchPathEvent(PathEvent event) {
|
private void dispatchPathEvent(PathEvent event) {
|
||||||
Baritone.INSTANCE.getExecutor().execute(() -> Baritone.INSTANCE.getGameEventHandler().onPathEvent(event));
|
Baritone.INSTANCE.getExecutor().execute(() -> Baritone.INSTANCE.getGameEventHandler().onPathEvent(event));
|
||||||
}
|
}
|
||||||
@ -391,6 +390,5 @@ public final class PathingBehavior extends Behavior implements Helper {
|
|||||||
// if (end - start > 0) {
|
// if (end - start > 0) {
|
||||||
// System.out.println("Frame took " + (split - start) + " " + (end - split));
|
// System.out.println("Frame took " + (split - start) + " " + (end - split));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,8 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
|
|
||||||
private final Optional<HashSet<BetterBlockPos>> favoredPositions;
|
private final Optional<HashSet<BetterBlockPos>> favoredPositions;
|
||||||
|
|
||||||
|
private final Random random = new Random();
|
||||||
|
|
||||||
public AStarPathFinder(BlockPos start, Goal goal, Optional<Collection<BetterBlockPos>> favoredPositions) {
|
public AStarPathFinder(BlockPos start, Goal goal, Optional<Collection<BetterBlockPos>> favoredPositions) {
|
||||||
super(start, goal);
|
super(start, goal);
|
||||||
this.favoredPositions = favoredPositions.map(HashSet::new); // <-- okay this is epic
|
this.favoredPositions = favoredPositions.map(HashSet::new); // <-- okay this is epic
|
||||||
@ -250,8 +252,6 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Random random = new Random();
|
|
||||||
|
|
||||||
private <T> void shuffle(T[] list) {
|
private <T> void shuffle(T[] list) {
|
||||||
int len = list.length;
|
int len = list.length;
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
|
@ -59,6 +59,12 @@ public abstract class Movement implements Helper, MovementHelper {
|
|||||||
|
|
||||||
private Double cost;
|
private Double cost;
|
||||||
|
|
||||||
|
public List<BlockPos> toBreakCached = null;
|
||||||
|
public List<BlockPos> toPlaceCached = null;
|
||||||
|
public List<BlockPos> toWalkIntoCached = null;
|
||||||
|
|
||||||
|
private Boolean calculatedWhileLoaded;
|
||||||
|
|
||||||
protected Movement(BetterBlockPos src, BetterBlockPos dest, BlockPos[] toBreak, BlockPos toPlace) {
|
protected Movement(BetterBlockPos src, BetterBlockPos dest, BlockPos[] toBreak, BlockPos toPlace) {
|
||||||
this.src = src;
|
this.src = src;
|
||||||
this.dest = dest;
|
this.dest = dest;
|
||||||
@ -290,8 +296,6 @@ public abstract class Movement implements Helper, MovementHelper {
|
|||||||
return getDest().subtract(getSrc());
|
return getDest().subtract(getSrc());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean calculatedWhileLoaded;
|
|
||||||
|
|
||||||
public void checkLoadedChunk() {
|
public void checkLoadedChunk() {
|
||||||
calculatedWhileLoaded = !(world().getChunk(getDest()) instanceof EmptyChunk);
|
calculatedWhileLoaded = !(world().getChunk(getDest()) instanceof EmptyChunk);
|
||||||
}
|
}
|
||||||
@ -300,10 +304,6 @@ public abstract class Movement implements Helper, MovementHelper {
|
|||||||
return calculatedWhileLoaded;
|
return calculatedWhileLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BlockPos> toBreakCached = null;
|
|
||||||
public List<BlockPos> toPlaceCached = null;
|
|
||||||
public List<BlockPos> toWalkIntoCached = null;
|
|
||||||
|
|
||||||
public List<BlockPos> toBreak() {
|
public List<BlockPos> toBreak() {
|
||||||
if (toBreakCached != null) {
|
if (toBreakCached != null) {
|
||||||
return toBreakCached;
|
return toBreakCached;
|
||||||
|
@ -27,14 +27,14 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
*/
|
*/
|
||||||
public final class BlockBreakHelper implements Helper {
|
public final class BlockBreakHelper implements Helper {
|
||||||
|
|
||||||
private BlockBreakHelper() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last block that we tried to break, if this value changes
|
* The last block that we tried to break, if this value changes
|
||||||
* between attempts, then we re-initialize the breaking process.
|
* between attempts, then we re-initialize the breaking process.
|
||||||
*/
|
*/
|
||||||
private static BlockPos lastBlock;
|
private static BlockPos lastBlock;
|
||||||
|
|
||||||
|
private BlockBreakHelper() {}
|
||||||
|
|
||||||
public static void tryBreakBlock(BlockPos pos, EnumFacing side) {
|
public static void tryBreakBlock(BlockPos pos, EnumFacing side) {
|
||||||
if (!pos.equals(lastBlock)) {
|
if (!pos.equals(lastBlock)) {
|
||||||
mc.playerController.clickBlock(pos, side);
|
mc.playerController.clickBlock(pos, side);
|
||||||
|
@ -50,12 +50,11 @@ import static org.lwjgl.opengl.GL11.*;
|
|||||||
*/
|
*/
|
||||||
public final class PathRenderer implements Helper {
|
public final class PathRenderer implements Helper {
|
||||||
|
|
||||||
private PathRenderer() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Tessellator TESSELLATOR = Tessellator.getInstance();
|
private static final Tessellator TESSELLATOR = Tessellator.getInstance();
|
||||||
private static final BufferBuilder BUFFER = TESSELLATOR.getBuffer();
|
private static final BufferBuilder BUFFER = TESSELLATOR.getBuffer();
|
||||||
|
|
||||||
|
private PathRenderer() {}
|
||||||
|
|
||||||
public static void drawPath(IPath path, int startIndex, EntityPlayerSP player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
|
public static void drawPath(IPath path, int startIndex, EntityPlayerSP player, float partialTicks, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||||
|
Loading…
Reference in New Issue
Block a user