2018-08-08 03:16:53 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Baritone.
|
|
|
|
*
|
|
|
|
* Baritone is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2018-08-08 04:15:22 +00:00
|
|
|
* Baritone is distributed in the hope that it will be useful,
|
2018-08-08 03:16:53 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-08-07 21:36:32 +00:00
|
|
|
package baritone.bot.pathing.movement;
|
|
|
|
|
2018-08-14 00:15:59 +00:00
|
|
|
import baritone.bot.Baritone;
|
2018-08-08 22:41:58 +00:00
|
|
|
import baritone.bot.utils.Helper;
|
2018-08-07 21:36:32 +00:00
|
|
|
import baritone.bot.utils.ToolSet;
|
2018-08-11 03:24:26 +00:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2018-08-08 22:41:58 +00:00
|
|
|
import net.minecraft.init.Items;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2018-08-07 21:36:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Brady
|
|
|
|
* @since 8/7/2018 4:30 PM
|
|
|
|
*/
|
2018-08-08 22:53:28 +00:00
|
|
|
public class CalculationContext implements Helper {
|
2018-08-07 21:36:32 +00:00
|
|
|
|
2018-08-11 03:24:26 +00:00
|
|
|
private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET);
|
|
|
|
|
2018-08-07 21:36:32 +00:00
|
|
|
private final ToolSet toolSet;
|
2018-08-08 22:41:58 +00:00
|
|
|
private final boolean hasWaterBucket;
|
2018-08-11 22:03:14 +00:00
|
|
|
private final boolean hasThrowaway;
|
2018-08-17 17:52:58 +00:00
|
|
|
private final boolean canSprint;
|
2018-08-17 20:17:16 +00:00
|
|
|
private final double placeBlockCost;
|
|
|
|
private final boolean allowBreak;
|
2018-08-22 00:16:00 +00:00
|
|
|
private final int maxFallHeightNoWater;
|
|
|
|
private final int maxFallHeightBucket;
|
2018-08-07 21:36:32 +00:00
|
|
|
|
|
|
|
public CalculationContext() {
|
|
|
|
this(new ToolSet());
|
|
|
|
}
|
|
|
|
|
|
|
|
public CalculationContext(ToolSet toolSet) {
|
2018-08-17 17:52:58 +00:00
|
|
|
player().setSprinting(true);
|
2018-08-07 21:36:32 +00:00
|
|
|
this.toolSet = toolSet;
|
2018-08-19 20:18:48 +00:00
|
|
|
this.hasThrowaway = Baritone.settings().allowPlace.get() && MovementHelper.throwaway(false);
|
2018-08-17 20:17:16 +00:00
|
|
|
this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.get() && InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER)) && !world().provider.isNether();
|
2018-08-17 17:52:58 +00:00
|
|
|
this.canSprint = Baritone.settings().allowSprint.get() && player().getFoodStats().getFoodLevel() > 6;
|
2018-08-17 20:17:16 +00:00
|
|
|
this.placeBlockCost = Baritone.settings().blockPlacementPenalty.get();
|
|
|
|
this.allowBreak = Baritone.settings().allowBreak.get();
|
2018-08-22 00:16:00 +00:00
|
|
|
this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.get();
|
|
|
|
this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.get();
|
2018-08-17 20:17:16 +00:00
|
|
|
// why cache these things here, why not let the movements just get directly from settings?
|
|
|
|
// because if some movements are calculated one way and others are calculated another way,
|
|
|
|
// then you get a wildly inconsistent path that isn't optimal for either scenario.
|
2018-08-07 21:36:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public ToolSet getToolSet() {
|
|
|
|
return this.toolSet;
|
|
|
|
}
|
2018-08-08 22:41:58 +00:00
|
|
|
|
|
|
|
public boolean hasWaterBucket() {
|
|
|
|
return hasWaterBucket;
|
|
|
|
}
|
2018-08-11 22:03:14 +00:00
|
|
|
|
|
|
|
public boolean hasThrowaway() {
|
|
|
|
return hasThrowaway;
|
|
|
|
}
|
2018-08-17 17:52:58 +00:00
|
|
|
|
|
|
|
public boolean canSprint() {
|
|
|
|
return canSprint;
|
|
|
|
}
|
2018-08-17 20:17:16 +00:00
|
|
|
|
|
|
|
public double placeBlockCost() {
|
|
|
|
return placeBlockCost;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean allowBreak() {
|
|
|
|
return allowBreak;
|
|
|
|
}
|
2018-08-20 14:11:15 +00:00
|
|
|
|
2018-08-22 00:16:00 +00:00
|
|
|
public int maxFallHeightNoWater() {
|
|
|
|
return maxFallHeightNoWater;
|
2018-08-20 14:11:15 +00:00
|
|
|
}
|
2018-08-22 00:16:00 +00:00
|
|
|
|
|
|
|
public int maxFallHeightBucket() {
|
|
|
|
return maxFallHeightBucket;
|
|
|
|
}
|
|
|
|
|
2018-08-07 21:36:32 +00:00
|
|
|
}
|