Merge pull request #2803 from scorbett123/farmInventory

Make farm use inventory when allowInventory is enabled.
This commit is contained in:
Leijurv 2021-06-14 12:32:53 -10:00 committed by GitHub
commit b96795c517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@
package baritone.behavior;
import baritone.Baritone;
import baritone.api.BaritoneAPI;
import baritone.api.event.events.TickEvent;
import baritone.utils.ToolSet;
import net.minecraft.block.Block;
@ -152,6 +153,10 @@ public final class InventoryBehavior extends Behavior {
}
public boolean throwaway(boolean select, Predicate<? super ItemStack> desired) {
return throwaway(select, desired, Baritone.settings().allowInventory.value);
}
public boolean throwaway(boolean select, Predicate<? super ItemStack> desired, boolean allowInventory) {
EntityPlayerSP p = ctx.player();
NonNullList<ItemStack> inv = p.inventory.mainInventory;
for (int i = 0; i < 9; i++) {
@ -184,6 +189,19 @@ public final class InventoryBehavior extends Behavior {
}
}
}
if (allowInventory) {
for (int i = 9; i < 36; i++) {
if (desired.test(inv.get(i))) {
swapWithHotBar(i, 7);
if (select) {
p.inventory.currentItem = 7;
}
return true;
}
}
}
return false;
}
}