Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into comeback-time
Browse files Browse the repository at this point in the history
  • Loading branch information
TacoTechnica authored Jan 18, 2022
2 parents eacc90d + 1bb7067 commit ea67ea5
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 13 deletions.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/major_bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Major Bug report
about: Report a bug that permanently STOPS the bot from progressing/requires HUMAN input to continue
title: ''
labels: 'major bug'
assignees: ''

---

## Steps to Reproduce (as best as you can)

## Expected Behavior

## Actual Behavior (What lead to the bot getting permanently stuck)

## Crashlogs and Screenshots (if applicable)
_(you may drag + drop text logs and images here, thanks GitHub)_
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
---
name: Bug report
about: Create a report to help squash bugs
name: Minor Bug report
about: Report a bug that TEMPORARILY interrupts the bot and/or wastes time, but does NOT permanently stop the bot/require human input to proceed.
title: ''
labels: ''
labels: 'minor bug'
assignees: ''

---

## Bug Description

## Steps to Reproduce (as best as you can)

## Expected Behavior
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/adris/altoclef/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public class Settings implements IFailableConfigFile {
private boolean showTaskChains = true;

/**
* If true, it will show a timer displaying how long the task was running.
* if false, it display the showTaskChains (if enabled) without the timer
*/
private boolean showTimer = true;

* The delay between moving items for crafting/furnace/any kind of inventory movement.
*/
private float containerItemMoveDelay = 0.2f;
Expand All @@ -72,7 +77,7 @@ public class Settings implements IFailableConfigFile {

/**
* amount of food to collect when the food in inventory
* is lower than the value of foodUnitsThreshold
* is lower than the value of minimumFoodAllowed
*/
private int foodUnitsToCollect = 0;

Expand Down Expand Up @@ -422,6 +427,9 @@ private static boolean idArrayContainsItem(Item item, int[] ids) {
public boolean shouldShowTaskChain() {
return showTaskChains;
}
public boolean shouldShowTimer() {
return showTimer;
}

public float getResourcePickupRange() {
return resourcePickupDropRange;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/adris/altoclef/chains/FoodChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void startEat(AltoClef mod, Item food) {
//Debug.logInternal("EATING " + toUse.getTranslationKey() + " : " + test);
_isTryingToEat = true;
_requestFillup = true;
mod.getSlotHandler().forceEquipItem(food);
mod.getSlotHandler().forceEquipItem(food, true); //"true" because it's food
mod.getInputControls().hold(Input.CLICK_RIGHT);
mod.getExtraBaritoneSettings().setInteractionPaused(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import adris.altoclef.util.helpers.StorageHelper;
import adris.altoclef.util.slots.PlayerInventorySlot;
import adris.altoclef.util.slots.Slot;
import adris.altoclef.util.slots.PlayerSlot;
import baritone.api.utils.input.Input;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public float getPriority(AltoClef mod) {
handleDrowning(mod);

// Lava Escape
if (isInLavaOhShit(mod)) {
if (isInLavaOhShit(mod) && mod.getBehaviour().shouldEscapeLava()) {
setTask(new EscapeFromLavaTask());
return 100;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ Get in position (XZ)
}
}


if (!mod.getEntityTracker().entityFound(EnderDragonEntity.class)) {
setDebugState("No dragon found.");
return new GetToXZTask(0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,15 @@ else if (_cachedEyeDirection != null) {
_netherGoalPos = new BlockPos(_strongholdEstimatePos.multiply(0.125, 0, 0.125));
_netherGoalPos = _netherGoalPos.add(0, PORTAL_TARGET_HEIGHT, 0);
}
if(mod.getPlayer().getPos().getX() - _netherGoalPos.getX() < Math.abs(15) && mod.getPlayer().getZ() - _netherGoalPos.getZ() < Math.abs(15) && mod.getPlayer().getPos().getY() > _netherGoalPos.getY()){
_netherGoalPos = new BlockPos(mod.getPlayer().getBlockPos().getX(), mod.getPlayer().getBlockPos().getY() + 1, mod.getPlayer().getBlockPos().getZ()); // ensure that baritone doesn't get lost over the lava since it has a hard time pathing large gaps of air blocks.
// Also ensures that we don't have to break blocks we are standing on to place the portal. Gets within 120 blocks of the stronghold.
}
if (_constructTask.isActive() && !_constructTask.isFinished(mod) || _netherGoalPos.isWithinDistance(mod.getPlayer().getPos(), _portalBuildRange)) {
if (_portalBuildRange == 2) {
_portalBuildRange = 20;
}

if (mod.getBlockTracker().getNearestWithinRange(mod.getPlayer().getPos(), _portalBuildRange, Blocks.NETHER_PORTAL) != null) {
_cachedEducatedPortal = mod.getBlockTracker().getNearestWithinRange(mod.getPlayer().getPos(), _portalBuildRange, Blocks.NETHER_PORTAL);
}
Expand Down
26 changes: 22 additions & 4 deletions src/main/java/adris/altoclef/ui/CommandStatusOverlay.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
package adris.altoclef.ui;

import adris.altoclef.AltoClef;
import adris.altoclef.Debug;
import adris.altoclef.tasksystem.Task;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.util.math.MatrixStack;

import java.util.Collections;
import java.util.List;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.ZoneId;
import java.time.ZoneOffset;

public class CommandStatusOverlay {

//For the ingame timer
private long _timeRunning;
private long _lastTime = 0;

public void render(AltoClef mod, MatrixStack matrixstack) {
if (mod.getModSettings().shouldShowTaskChain()) {
List<Task> tasks = Collections.emptyList();
Expand All @@ -19,16 +28,25 @@ public void render(AltoClef mod, MatrixStack matrixstack) {
}

int color = 0xFFFFFFFF;
drawTaskChain(MinecraftClient.getInstance().textRenderer, matrixstack, 0, 0, color, 10, tasks);
drawTaskChain(MinecraftClient.getInstance().textRenderer, matrixstack, 0, 0, color, 10, tasks, mod);
}
}

private void drawTaskChain(TextRenderer renderer, MatrixStack stack, float dx, float dy, int color, int maxLines, List<Task> tasks) {
private DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss.SSS").withZone(ZoneId.from(ZoneOffset.of("+00:00"))); // The date formatter
private void drawTaskChain(TextRenderer renderer, MatrixStack stack, float dx, float dy, int color, int maxLines, List<Task> tasks, AltoClef mod) {
if (tasks.size() == 0) {
renderer.draw(stack, " (no task running) ", dx, dy, color);
if (_lastTime+10000 < Instant.now().toEpochMilli() && mod.getModSettings().shouldShowTimer()) {//if it doesn't run any task in 10 secs
_timeRunning = Instant.now().toEpochMilli();//reset the timer
}
} else {
float fontHeight = renderer.fontHeight;

if (mod.getModSettings().shouldShowTimer()) { //If it's enabled
_lastTime = Instant.now().toEpochMilli(); //keep the last time for the timer reset
String _realTime = DATE_TIME_FORMATTER.format(Instant.now().minusMillis(_timeRunning)); //Format the running time to string
renderer.draw(stack, "<"+_realTime+">", dx, dy, color);//Draw the timer before drawing tasks list
dx += 8;//Do the same thing to list the tasks
dy += fontHeight + 2;
}
if (tasks.size() > maxLines) {
for (int i = 0; i < tasks.size(); ++i) {
// Skip over the next tasks
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/adris/altoclef/util/control/BotBehaviour.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,26 @@ public BotBehaviour(AltoClef mod) {
push();
}

// Getter(s)
/**
* Returns the current state of Behaviour for escapeLava
* @return The current state of Behaviour for escapeLava
*/
public boolean shouldEscapeLava() {
return current().escapeLava;
}

/// Parameters

/**
* If the bot should escape lava or not, part of WorldSurvivalChain
* @param allow True if the bot should escape lava
*/
public void setEscapeLava(boolean allow) {
current().escapeLava = allow;
current().applyState();
}

public void setFollowDistance(double distance) {
current().followOffsetDistance = distance;
current().applyState();
Expand Down Expand Up @@ -235,6 +253,9 @@ class State {
// Hard coded stuff
public RaycastContext.FluidHandling rayFluidHandling;

// Other necessary stuff
public boolean escapeLava = true;

public State() {
this(null);
}
Expand All @@ -253,6 +274,7 @@ public State(State toCopy) {
avoidDodgingProjectile.addAll(toCopy.avoidDodgingProjectile);
excludeFromForceField.addAll(toCopy.excludeFromForceField);
forceFieldPlayers = toCopy.forceFieldPlayers;
escapeLava = toCopy.escapeLava;
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/adris/altoclef/util/control/SlotHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ public boolean forceEquipItem(Item toEquip) {
Debug.logWarning("Failed to equip item " + toEquip.getTranslationKey());
return false;
}
//Default forceEquipItem, will not force to equip item if the bot eat
public boolean forceEquipItem(Item toEquip) {
return forceEquipItem(toEquip, false);
}
public boolean forceDeequipHitTool() {
return forceDeequip(stack -> stack.getItem() instanceof ToolItem);
}
Expand Down

0 comments on commit ea67ea5

Please sign in to comment.