parent
af0c3bbd5c
commit
c4c85b4f49
@ -18,6 +18,7 @@
|
|||||||
package baritone.api;
|
package baritone.api;
|
||||||
|
|
||||||
import baritone.api.utils.SettingsUtil;
|
import baritone.api.utils.SettingsUtil;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
@ -146,6 +147,13 @@ public final class Settings {
|
|||||||
Item.getItemFromBlock(Blocks.STONE)
|
Item.getItemFromBlock(Blocks.STONE)
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blocks that Baritone will attempt to avoid (Used in avoidance)
|
||||||
|
*/
|
||||||
|
public final Setting<List<Block>> blocksToAvoid = new Setting<>(new ArrayList<>(Arrays.asList(
|
||||||
|
Blocks.VINE
|
||||||
|
)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables some more advanced vine features. They're honestly just gimmicks and won't ever be needed in real
|
* Enables some more advanced vine features. They're honestly just gimmicks and won't ever be needed in real
|
||||||
* pathing scenarios. And they can cause Baritone to get trapped indefinitely in a strange scenario.
|
* pathing scenarios. And they can cause Baritone to get trapped indefinitely in a strange scenario.
|
||||||
@ -250,6 +258,15 @@ public final class Settings {
|
|||||||
|
|
||||||
public final Setting<Integer> mobAvoidanceRadius = new Setting<>(8);
|
public final Setting<Integer> mobAvoidanceRadius = new Setting<>(8);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to 1.0 to effectively disable this feature
|
||||||
|
* <p>
|
||||||
|
* Set below 1.0 to go out of your way to walk near blocks
|
||||||
|
*/
|
||||||
|
public final Setting<Double> blockAvoidanceCoefficient = new Setting<>(1.5);
|
||||||
|
|
||||||
|
public final Setting<Integer> blockAvoidanceRadius = new Setting<>(8);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When running a goto towards a container block (chest, ender chest, furnace, etc),
|
* When running a goto towards a container block (chest, ender chest, furnace, etc),
|
||||||
* right click and open it once you arrive.
|
* right click and open it once you arrive.
|
||||||
|
@ -74,6 +74,9 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.WEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockSkull || block instanceof BlockTrapDoor) {
|
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.WEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof BlockSkull || block instanceof BlockTrapDoor) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (Baritone.settings().blocksToAvoid.value.contains(block)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (block instanceof BlockDoor || block instanceof BlockFenceGate) {
|
if (block instanceof BlockDoor || block instanceof BlockFenceGate) {
|
||||||
// Because there's no nice method in vanilla to check if a door is openable or not, we just have to assume
|
// Because there's no nice method in vanilla to check if a door is openable or not, we just have to assume
|
||||||
// that anything that isn't an iron door isn't openable, ignoring that some doors introduced in mods can't
|
// that anything that isn't an iron door isn't openable, ignoring that some doors introduced in mods can't
|
||||||
|
@ -19,8 +19,10 @@ package baritone.utils.pathing;
|
|||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
|
import baritone.api.utils.BlockUtils;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.monster.EntityMob;
|
import net.minecraft.entity.monster.EntityMob;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
@ -63,12 +65,18 @@ public class Avoidance {
|
|||||||
List<Avoidance> res = new ArrayList<>();
|
List<Avoidance> res = new ArrayList<>();
|
||||||
double mobSpawnerCoeff = Baritone.settings().mobSpawnerAvoidanceCoefficient.value;
|
double mobSpawnerCoeff = Baritone.settings().mobSpawnerAvoidanceCoefficient.value;
|
||||||
double mobCoeff = Baritone.settings().mobAvoidanceCoefficient.value;
|
double mobCoeff = Baritone.settings().mobAvoidanceCoefficient.value;
|
||||||
|
double blockCoeff = Baritone.settings().blockAvoidanceCoefficient.value;
|
||||||
if (mobSpawnerCoeff != 1.0D) {
|
if (mobSpawnerCoeff != 1.0D) {
|
||||||
ctx.worldData().getCachedWorld().getLocationsOf("mob_spawner", 1, ctx.playerFeet().x, ctx.playerFeet().z, 2).forEach(mobspawner -> res.add(new Avoidance(mobspawner, mobSpawnerCoeff, Baritone.settings().mobSpawnerAvoidanceRadius.value)));
|
ctx.worldData().getCachedWorld().getLocationsOf("mob_spawner", 1, ctx.playerFeet().x, ctx.playerFeet().z, 2).forEach(mobspawner -> res.add(new Avoidance(mobspawner, mobSpawnerCoeff, Baritone.settings().mobSpawnerAvoidanceRadius.value)));
|
||||||
}
|
}
|
||||||
if (mobCoeff != 1.0D) {
|
if (mobCoeff != 1.0D) {
|
||||||
ctx.world().loadedEntityList.stream().filter(entity -> entity instanceof EntityMob).forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
|
ctx.world().loadedEntityList.stream().filter(entity -> entity instanceof EntityMob).forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
|
||||||
}
|
}
|
||||||
|
if (blockCoeff != 1.0D) {
|
||||||
|
for (Block block : Baritone.settings().blocksToAvoid.value) {
|
||||||
|
ctx.worldData().getCachedWorld().getLocationsOf(BlockUtils.blockToString(block), 1, ctx.playerFeet().x, ctx.playerFeet().z, 2).forEach(blockPos -> res.add(new Avoidance(blockPos, blockCoeff, Baritone.settings().blockAvoidanceRadius.value)));
|
||||||
|
}
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user