lookmanager
This commit is contained in:
parent
5d4ea57503
commit
c59d8bae7c
@ -385,11 +385,11 @@ public class Baritone {
|
|||||||
*/
|
*/
|
||||||
public static BlockPos whatAreYouLookingAt() {
|
public static BlockPos whatAreYouLookingAt() {
|
||||||
/*Minecraft mc = Minecraft.getMinecraft();
|
/*Minecraft mc = Minecraft.getMinecraft();
|
||||||
if (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
if (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||||
return mc.objectMouseOver.getBlockPos();
|
return mc.objectMouseOver.getBlockPos();
|
||||||
}
|
}
|
||||||
return null;*/
|
return null;*/
|
||||||
throw new UnsupportedOperationException("need to figure out what MovingObjectPosition is in 1.12.2");
|
throw new UnsupportedOperationException("need to figure out what RayTraceResult is in 1.12.2");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void switchToBestTool() {
|
public static void switchToBestTool() {
|
||||||
@ -414,10 +414,10 @@ public class Baritone {
|
|||||||
|
|
||||||
public static Entity whatEntityAreYouLookingAt() {
|
public static Entity whatEntityAreYouLookingAt() {
|
||||||
/*Minecraft mc = Minecraft.getMinecraft();
|
/*Minecraft mc = Minecraft.getMinecraft();
|
||||||
if (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
|
if (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == RayTraceResult.Type.ENTITY) {
|
||||||
return mc.objectMouseOver.entityHit;
|
return mc.objectMouseOver.entityHit;
|
||||||
}*/
|
}*/
|
||||||
throw new UnsupportedOperationException("need to figure out what MovingObjectPosition is in 1.12.2");
|
throw new UnsupportedOperationException("need to figure out what RayTraceResult is in 1.12.2");
|
||||||
//return null;
|
//return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,304 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package baritone.strategy;
|
|
||||||
|
|
||||||
import baritone.movement.Combat;
|
|
||||||
import baritone.util.BlockPuncher;
|
|
||||||
import baritone.mining.MickeyMine;
|
|
||||||
import baritone.inventory.CraftingTask;
|
|
||||||
import baritone.util.Manager;
|
|
||||||
import baritone.util.ManagerTick;
|
|
||||||
import baritone.util.Out;
|
|
||||||
import baritone.inventory.SmeltingTask;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemArmor;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.ItemTool;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* goals:
|
|
||||||
*
|
|
||||||
* get dirt
|
|
||||||
*
|
|
||||||
* get wood
|
|
||||||
*
|
|
||||||
* make a crafting table
|
|
||||||
*
|
|
||||||
* make a wooden pickaxe
|
|
||||||
*
|
|
||||||
* get stone
|
|
||||||
*
|
|
||||||
* make a stone pickaxe
|
|
||||||
*
|
|
||||||
* get more stone
|
|
||||||
*
|
|
||||||
* make stone tools and a furnace
|
|
||||||
*
|
|
||||||
* go mining at level 36
|
|
||||||
*
|
|
||||||
* craft torches
|
|
||||||
*
|
|
||||||
* smelt iron
|
|
||||||
*
|
|
||||||
* make iron pick and iron armor and an iron sword
|
|
||||||
*
|
|
||||||
* change mining level to 6
|
|
||||||
*
|
|
||||||
* craft a diamond pickaxe
|
|
||||||
*
|
|
||||||
* @author leijurv
|
|
||||||
*/
|
|
||||||
public class EarlyGameStrategy extends ManagerTick {
|
|
||||||
static boolean gotWood_PHRASING = false;
|
|
||||||
static int WOOD_AMT = 16;//triggers stopping
|
|
||||||
static int MIN_WOOD_AMT = 1;//triggers getting more
|
|
||||||
static final int DIRT_AMT = 32;
|
|
||||||
static boolean gotDirt = false;
|
|
||||||
static boolean cobble = false;
|
|
||||||
@Override
|
|
||||||
protected boolean onTick0() {
|
|
||||||
if (!gotDirt) {
|
|
||||||
int dirt = countDirt();
|
|
||||||
if (dirt >= DIRT_AMT) {
|
|
||||||
Out.gui("Done getting dirt", Out.Mode.Debug);
|
|
||||||
gotDirt = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!BlockPuncher.tick("dirt", "grass")) {
|
|
||||||
Out.gui("No dirt or grass nearby =(", Out.Mode.Debug);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int wood = countWood_PHRASING();
|
|
||||||
if (wood >= WOOD_AMT) {
|
|
||||||
if (!gotWood_PHRASING) {
|
|
||||||
Out.gui("Done getting wood", Out.Mode.Debug);
|
|
||||||
}
|
|
||||||
gotWood_PHRASING = true;
|
|
||||||
}
|
|
||||||
if (wood < MIN_WOOD_AMT) {
|
|
||||||
if (gotWood_PHRASING) {
|
|
||||||
Out.gui("Getting more wood", Out.Mode.Debug);
|
|
||||||
}
|
|
||||||
gotWood_PHRASING = false;
|
|
||||||
}
|
|
||||||
if (!gotWood_PHRASING) {
|
|
||||||
if (!BlockPuncher.tick("log", "log2")) {
|
|
||||||
Out.gui("No wood nearby =(", Out.Mode.Debug);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
boolean hasWooden = false;
|
|
||||||
boolean readyForMining = true;
|
|
||||||
boolean hasStone = craftTool(Item.getByNameOrId("minecraft:stone_pickaxe"), 1);
|
|
||||||
if (hasStone) {
|
|
||||||
dontCraft(Item.getByNameOrId("minecraft:wooden_pickaxe"));
|
|
||||||
} else {
|
|
||||||
hasWooden = craftTool(Item.getByNameOrId("minecraft:wooden_pickaxe"), 1);
|
|
||||||
}
|
|
||||||
readyForMining &= hasStone;
|
|
||||||
if (hasWooden || hasStone) {
|
|
||||||
if (!cobble) {
|
|
||||||
if (countCobble() > 16) {
|
|
||||||
cobble = true;
|
|
||||||
} else if (!BlockPuncher.tick("stone")) {
|
|
||||||
Out.gui("No stone nearby =(", Out.Mode.Debug);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!cobble) {
|
|
||||||
readyForMining = false;
|
|
||||||
}
|
|
||||||
if (cobble && gotDirt && countCobble() + countDirt() < 10) {//if we have already gotten cobble and dirt, but our amounts have run low, get more
|
|
||||||
if (!BlockPuncher.tick("dirt", "grass", "stone")) {
|
|
||||||
Out.gui("No dirt, grass, or stone", Out.Mode.Debug);
|
|
||||||
}
|
|
||||||
readyForMining = false;
|
|
||||||
}
|
|
||||||
if (countCobble() > 5) {
|
|
||||||
boolean axe = craftTool(Item.getByNameOrId("minecraft:stone_axe"), 1);
|
|
||||||
if (axe) {
|
|
||||||
WOOD_AMT = 64;
|
|
||||||
MIN_WOOD_AMT = 16;
|
|
||||||
} else {
|
|
||||||
readyForMining = false;
|
|
||||||
}
|
|
||||||
if (!craftTool(Item.getByNameOrId("minecraft:stone_shovel"), 1)) {
|
|
||||||
readyForMining = false;
|
|
||||||
}
|
|
||||||
if (!craftTool(Item.getByNameOrId("minecraft:stone_sword"), 1)) {
|
|
||||||
readyForMining = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (countCobble() > 8) {
|
|
||||||
if (!craftTool(Item.getByNameOrId("minecraft:furnace"), 1)) {
|
|
||||||
readyForMining = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int miningLevel = MickeyMine.Y_IRON;
|
|
||||||
if (readyForMining) {
|
|
||||||
int amtIron = 0;
|
|
||||||
boolean ironPick = craftTool(Item.getByNameOrId("minecraft:iron_pickaxe"), 1);
|
|
||||||
if (ironPick) {
|
|
||||||
boolean ironSword = craftTool(Item.getByNameOrId("minecraft:iron_sword"), 1);
|
|
||||||
if (ironSword) {
|
|
||||||
boolean ironHelmet = craftTool(Item.getByNameOrId("minecraft:iron_helmet"), 1);
|
|
||||||
boolean ironChestplate = craftTool(Item.getByNameOrId("minecraft:iron_chestplate"), 1);
|
|
||||||
boolean ironLeggings = craftTool(Item.getByNameOrId("minecraft:iron_leggings"), 1);
|
|
||||||
boolean ironBoots = craftTool(Item.getByNameOrId("minecraft:iron_boots"), 1);
|
|
||||||
if (ironHelmet && ironChestplate && ironLeggings && ironBoots) {
|
|
||||||
miningLevel = MickeyMine.Y_DIAMOND;
|
|
||||||
} else {
|
|
||||||
amtIron = (!ironHelmet ? 5 : 0) + (!ironChestplate ? 8 : 0) + (!ironLeggings ? 7 : 0) + (!ironBoots ? 4 : 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
amtIron = 2;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
amtIron = 3;
|
|
||||||
}
|
|
||||||
int currIron = countItem("minecraft:iron_ingot");
|
|
||||||
boolean hasOre = countItem("iron_ore") >= amtIron - currIron;
|
|
||||||
if (hasOre && currIron < amtIron) {
|
|
||||||
int tasksForIron = SmeltingTask.tasksFor(Item.getByNameOrId("iron_ingot"));
|
|
||||||
int newTask = amtIron - currIron - tasksForIron;
|
|
||||||
if (newTask > 0) {
|
|
||||||
new SmeltingTask(new ItemStack(Item.getByNameOrId("iron_ingot"), Math.min(countItem("iron_ore"), 64))).begin();
|
|
||||||
}
|
|
||||||
readyForMining = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int numDiamonds = countItem("diamond");
|
|
||||||
if (readyForMining && numDiamonds >= 1) {
|
|
||||||
if (craftTool(Item.getByNameOrId("diamond_pickaxe"), 1)) {
|
|
||||||
if (craftTool(Item.getByNameOrId("diamond_sword"), 1)) {
|
|
||||||
if (craftTool(Item.getByNameOrId("diamond_chestplate"), 1)) {
|
|
||||||
if (craftTool(Item.getByNameOrId("diamond_leggings"), 1)) {
|
|
||||||
if (craftTool(Item.getByNameOrId("diamond_helmet"), 1)) {
|
|
||||||
if (craftTool(Item.getByNameOrId("diamond_boots"), 1)) {
|
|
||||||
if (craftTool(Item.getByNameOrId("diamond_axe"), 1)) {
|
|
||||||
if (craftTool(Item.getByNameOrId("diamond_shovel"), 1)) {
|
|
||||||
Out.gui("My job here is done.", Out.Mode.Minimal);
|
|
||||||
cancel();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Manager instance = Manager.getManager(MickeyMine.class);
|
|
||||||
if (readyForMining) {
|
|
||||||
MickeyMine.yLevel = miningLevel;
|
|
||||||
if (!instance.enabled()) {
|
|
||||||
instance.toggle();
|
|
||||||
}
|
|
||||||
} else if (instance.enabled()) {
|
|
||||||
instance.toggle();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public static boolean craftTool(Item tool, int amt) {
|
|
||||||
if (tool instanceof ItemTool) {
|
|
||||||
for (ItemStack stack : Minecraft.getMinecraft().player.inventory.mainInventory) {
|
|
||||||
if (stack == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (stack.getItem() instanceof ItemTool && stack.getItem().getClass() == tool.getClass()) {
|
|
||||||
ItemTool t = (ItemTool) (stack.getItem());
|
|
||||||
if (t.getToolMaterial().getEfficiencyOnProperMaterial() >= ((ItemTool) tool).getToolMaterial().getEfficiencyOnProperMaterial()) {
|
|
||||||
//Out.gui("Saying has " + new ItemStack(tool, 0) + " because has " + stack);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CraftingTask.ensureCraftingDesired(tool, amt);
|
|
||||||
}
|
|
||||||
if (tool instanceof ItemArmor) {
|
|
||||||
ItemArmor armor = (ItemArmor) tool;
|
|
||||||
for (ItemStack stack : Minecraft.getMinecraft().player.inventory.mainInventory) {
|
|
||||||
if (stack == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (stack.getItem() instanceof ItemArmor) {
|
|
||||||
ItemArmor a = (ItemArmor) (stack.getItem());
|
|
||||||
if (a.armorType == armor.armorType) {
|
|
||||||
if (a.damageReduceAmount >= armor.damageReduceAmount) {
|
|
||||||
//Out.gui("Saying has " + new ItemStack(tool, 0) + " because has " + stack);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (ItemStack stack : Minecraft.getMinecraft().player.inventory.armorInventory) {
|
|
||||||
if (stack == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ItemArmor a = (ItemArmor) (stack.getItem());
|
|
||||||
if (a.armorType == armor.armorType) {
|
|
||||||
if (a.damageReduceAmount >= armor.damageReduceAmount) {
|
|
||||||
//Out.gui("Saying has " + new ItemStack(tool, 0) + " because has " + stack);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CraftingTask.ensureCraftingDesired(tool, amt);
|
|
||||||
}
|
|
||||||
public static void dontCraft(Item item) {
|
|
||||||
CraftingTask task = CraftingTask.findOrCreateCraftingTask(new ItemStack(item, 0));
|
|
||||||
if (task.currentlyCrafting().stackSize > 0) {
|
|
||||||
task.decreaseNeededAmount(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static int countItem(String s) {
|
|
||||||
Item item = Item.getByNameOrId(s);
|
|
||||||
int count = 0;
|
|
||||||
for (ItemStack stack : Minecraft.getMinecraft().player.inventory.mainInventory) {
|
|
||||||
if (stack == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (item.equals(stack.getItem())) {
|
|
||||||
count += stack.stackSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
public static int countWood_PHRASING() {
|
|
||||||
return countItem("log") + countItem("log2");
|
|
||||||
}
|
|
||||||
public static int countDirt() {
|
|
||||||
return countItem("dirt");
|
|
||||||
}
|
|
||||||
public static int countCobble() {
|
|
||||||
return countItem("cobblestone");
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onCancel() {
|
|
||||||
gotWood_PHRASING = false;
|
|
||||||
WOOD_AMT = 16;
|
|
||||||
MIN_WOOD_AMT = 1;
|
|
||||||
gotDirt = false;
|
|
||||||
cobble = false;
|
|
||||||
Combat.mobKilling = false;
|
|
||||||
SmeltingTask.coalOnly = false;
|
|
||||||
Manager.getManager(MickeyMine.class).cancel();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onStart() {
|
|
||||||
gotWood_PHRASING = false;
|
|
||||||
WOOD_AMT = 16;
|
|
||||||
MIN_WOOD_AMT = 1;
|
|
||||||
gotDirt = false;
|
|
||||||
cobble = false;
|
|
||||||
Combat.mobKilling = true;
|
|
||||||
SmeltingTask.coalOnly = true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,25 +5,28 @@
|
|||||||
*/
|
*/
|
||||||
package baritone.ui;
|
package baritone.ui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import baritone.Baritone;
|
||||||
import java.util.Random;
|
|
||||||
import baritone.pathfinding.goals.GoalXZ;
|
import baritone.pathfinding.goals.GoalXZ;
|
||||||
import baritone.util.Manager;
|
import baritone.util.Manager;
|
||||||
import net.minecraft.block.Block;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
import net.minecraft.block.BlockFire;
|
import net.minecraft.block.BlockFire;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityPlayerSP;
|
import net.minecraft.client.entity.EntityPlayerSP;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author leijurv
|
* @author leijurv
|
||||||
*/
|
*/
|
||||||
public class LookManager extends Manager {
|
public class LookManager extends Manager {
|
||||||
|
|
||||||
public static boolean randomLooking = true;
|
public static boolean randomLooking = true;
|
||||||
static final float MAX_YAW_CHANGE_PER_TICK = 360 / 20;
|
static final float MAX_YAW_CHANGE_PER_TICK = 360 / 20;
|
||||||
static final float MAX_PITCH_CHANGE_PER_TICK = 360 / 20;
|
static final float MAX_PITCH_CHANGE_PER_TICK = 360 / 20;
|
||||||
@ -56,6 +59,7 @@ public class LookManager extends Manager {
|
|||||||
* desiredPitch
|
* desiredPitch
|
||||||
*/
|
*/
|
||||||
static boolean lookingPitch = false;
|
static boolean lookingPitch = false;
|
||||||
|
|
||||||
public static void frame(float partialTicks) {
|
public static void frame(float partialTicks) {
|
||||||
//Out.log("Part: " + partialTicks);
|
//Out.log("Part: " + partialTicks);
|
||||||
if (Minecraft.getMinecraft() == null || Minecraft.getMinecraft().player == null) {
|
if (Minecraft.getMinecraft() == null || Minecraft.getMinecraft().player == null) {
|
||||||
@ -72,6 +76,7 @@ public class LookManager extends Manager {
|
|||||||
* Because I had to do it the janky way
|
* Because I had to do it the janky way
|
||||||
*/
|
*/
|
||||||
private static final double[][] BLOCK_SIDE_MULTIPLIERS = {{0, 0.5, 0.5}, {1, 0.5, 0.5}, {0.5, 0, 0.5}, {0.5, 1, 0.5}, {0.5, 0.5, 0}, {0.5, 0.5, 1}};
|
private static final double[][] BLOCK_SIDE_MULTIPLIERS = {{0, 0.5, 0.5}, {1, 0.5, 0.5}, {0.5, 0, 0.5}, {0.5, 1, 0.5}, {0.5, 0.5, 0}, {0.5, 0.5, 1}};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by our code in order to look in the direction of the center of a
|
* Called by our code in order to look in the direction of the center of a
|
||||||
* block
|
* block
|
||||||
@ -86,11 +91,12 @@ public class LookManager extends Manager {
|
|||||||
if (couldIReachCenter(p)) {
|
if (couldIReachCenter(p)) {
|
||||||
return lookAtCenterOfBlock(p, alsoDoPitch);
|
return lookAtCenterOfBlock(p, alsoDoPitch);
|
||||||
}
|
}
|
||||||
Block b = Baritone.get(p).getBlock();
|
IBlockState b = Baritone.get(p);
|
||||||
|
AxisAlignedBB bbox = b.getBoundingBox(Baritone.world, p);
|
||||||
for (double[] mult : BLOCK_SIDE_MULTIPLIERS) {
|
for (double[] mult : BLOCK_SIDE_MULTIPLIERS) {
|
||||||
double xDiff = b.getBlockBoundsMinX() * mult[0] + b.getBlockBoundsMaxX() * (1 - mult[0]);//lol
|
double xDiff = bbox.minX * mult[0] + bbox.maxX * (1 - mult[0]);//lol
|
||||||
double yDiff = b.getBlockBoundsMinY() * mult[1] + b.getBlockBoundsMaxY() * (1 - mult[1]);
|
double yDiff = bbox.minY * mult[1] + bbox.maxY * (1 - mult[1]);
|
||||||
double zDiff = b.getBlockBoundsMinZ() * mult[2] + b.getBlockBoundsMaxZ() * (1 - mult[2]);
|
double zDiff = bbox.minZ * mult[2] + bbox.maxZ * (1 - mult[2]);
|
||||||
double x = p.getX() + xDiff;
|
double x = p.getX() + xDiff;
|
||||||
double y = p.getY() + yDiff;
|
double y = p.getY() + yDiff;
|
||||||
double z = p.getZ() + zDiff;
|
double z = p.getZ() + zDiff;
|
||||||
@ -100,11 +106,13 @@ public class LookManager extends Manager {
|
|||||||
}
|
}
|
||||||
return lookAtCenterOfBlock(p, alsoDoPitch);
|
return lookAtCenterOfBlock(p, alsoDoPitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean lookAtCenterOfBlock(BlockPos p, boolean alsoDoPitch) {
|
public static boolean lookAtCenterOfBlock(BlockPos p, boolean alsoDoPitch) {
|
||||||
Block b = Baritone.get(p).getBlock();
|
IBlockState b = Baritone.get(p);
|
||||||
double xDiff = (b.getBlockBoundsMinX() + b.getBlockBoundsMaxX()) / 2;
|
AxisAlignedBB bbox = b.getBoundingBox(Baritone.world, p);
|
||||||
double yDiff = (b.getBlockBoundsMinY() + b.getBlockBoundsMaxY()) / 2;
|
double xDiff = (bbox.minX + bbox.maxX) / 2;
|
||||||
double zDiff = (b.getBlockBoundsMinZ() + b.getBlockBoundsMaxZ()) / 2;
|
double yDiff = (bbox.minY + bbox.maxY) / 2;
|
||||||
|
double zDiff = (bbox.minZ + bbox.maxZ) / 2;
|
||||||
if (b instanceof BlockFire) {//look at bottom of fire when putting it out
|
if (b instanceof BlockFire) {//look at bottom of fire when putting it out
|
||||||
yDiff = 0;
|
yDiff = 0;
|
||||||
}
|
}
|
||||||
@ -117,15 +125,17 @@ public class LookManager extends Manager {
|
|||||||
* The threshold for how close it tries to get to looking straight at things
|
* The threshold for how close it tries to get to looking straight at things
|
||||||
*/
|
*/
|
||||||
public static final float ANGLE_THRESHOLD = 7;
|
public static final float ANGLE_THRESHOLD = 7;
|
||||||
|
|
||||||
public static boolean couldIReach(BlockPos pos) {
|
public static boolean couldIReach(BlockPos pos) {
|
||||||
if (couldIReachCenter(pos)) {
|
if (couldIReachCenter(pos)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Block b = Baritone.get(pos).getBlock();
|
IBlockState b = Baritone.get(pos);
|
||||||
|
AxisAlignedBB bbox = b.getBoundingBox(Baritone.world, pos);
|
||||||
for (double[] mult : BLOCK_SIDE_MULTIPLIERS) {
|
for (double[] mult : BLOCK_SIDE_MULTIPLIERS) {
|
||||||
double xDiff = b.getBlockBoundsMinX() * mult[0] + b.getBlockBoundsMaxX() * (1 - mult[0]);
|
double xDiff = bbox.minX * mult[0] + bbox.maxX * (1 - mult[0]);//lol
|
||||||
double yDiff = b.getBlockBoundsMinY() * mult[1] + b.getBlockBoundsMaxY() * (1 - mult[1]);
|
double yDiff = bbox.minY * mult[1] + bbox.maxY * (1 - mult[1]);
|
||||||
double zDiff = b.getBlockBoundsMinZ() * mult[2] + b.getBlockBoundsMaxZ() * (1 - mult[2]);
|
double zDiff = bbox.minZ * mult[2] + bbox.maxZ * (1 - mult[2]);
|
||||||
double x = pos.getX() + xDiff;
|
double x = pos.getX() + xDiff;
|
||||||
double y = pos.getY() + yDiff;
|
double y = pos.getY() + yDiff;
|
||||||
double z = pos.getZ() + zDiff;
|
double z = pos.getZ() + zDiff;
|
||||||
@ -135,53 +145,62 @@ public class LookManager extends Manager {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean couldIReachCenter(BlockPos pos) {
|
public static boolean couldIReachCenter(BlockPos pos) {
|
||||||
float[] pitchAndYaw = pitchAndYawToCenter(pos);
|
float[] pitchAndYaw = pitchAndYawToCenter(pos);
|
||||||
MovingObjectPosition blah = raytraceTowards(pitchAndYaw);
|
RayTraceResult blah = raytraceTowards(pitchAndYaw);
|
||||||
return blah != null && blah.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && blah.getBlockPos().equals(pos);
|
return blah != null && blah.typeOfHit == RayTraceResult.Type.BLOCK && blah.getBlockPos().equals(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean couldIReach(BlockPos pos, EnumFacing dir) {
|
public static boolean couldIReach(BlockPos pos, EnumFacing dir) {
|
||||||
BlockPos side = pos.offset(dir);
|
BlockPos side = pos.offset(dir);
|
||||||
double faceX = (pos.getX() + side.getX() + 1.0D) * 0.5D;
|
double faceX = (pos.getX() + side.getX() + 1.0D) * 0.5D;
|
||||||
double faceY = (pos.getY() + side.getY()) * 0.5D;
|
double faceY = (pos.getY() + side.getY()) * 0.5D;
|
||||||
double faceZ = (pos.getZ() + side.getZ() + 1.0D) * 0.5D;
|
double faceZ = (pos.getZ() + side.getZ() + 1.0D) * 0.5D;
|
||||||
MovingObjectPosition blah = raytraceTowards(faceX, faceY, faceZ);
|
RayTraceResult blah = raytraceTowards(faceX, faceY, faceZ);
|
||||||
return blah != null && blah.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && blah.getBlockPos().equals(pos) && blah.sideHit == dir;
|
return blah != null && blah.typeOfHit == RayTraceResult.Type.BLOCK && blah.getBlockPos().equals(pos) && blah.sideHit == dir;
|
||||||
}
|
}
|
||||||
public static MovingObjectPosition raytraceTowards(double x, double y, double z) {
|
|
||||||
|
public static RayTraceResult raytraceTowards(double x, double y, double z) {
|
||||||
return raytraceTowards(pitchAndYaw(x, y, z));
|
return raytraceTowards(pitchAndYaw(x, y, z));
|
||||||
}
|
}
|
||||||
public static MovingObjectPosition raytraceTowards(float[] pitchAndYaw) {
|
|
||||||
|
public static RayTraceResult raytraceTowards(float[] pitchAndYaw) {
|
||||||
float yaw = pitchAndYaw[0];
|
float yaw = pitchAndYaw[0];
|
||||||
float pitch = pitchAndYaw[1];
|
float pitch = pitchAndYaw[1];
|
||||||
double blockReachDistance = (double) Minecraft.getMinecraft().playerController.getBlockReachDistance();
|
double blockReachDistance = (double) Minecraft.getMinecraft().playerController.getBlockReachDistance();
|
||||||
Vec3 vec3 = Minecraft.getMinecraft().player.getPositionEyes(1.0F);
|
Vec3d vec3 = Minecraft.getMinecraft().player.getPositionEyes(1.0F);
|
||||||
Vec3 vec31 = getVectorForRotation(pitch, yaw);
|
Vec3d vec31 = getVectorForRotation(pitch, yaw);
|
||||||
Vec3 vec32 = vec3.addVector(vec31.xCoord * blockReachDistance, vec31.yCoord * blockReachDistance, vec31.zCoord * blockReachDistance);
|
Vec3d vec32 = vec3.addVector(vec31.xCoord * blockReachDistance, vec31.yCoord * blockReachDistance, vec31.zCoord * blockReachDistance);
|
||||||
MovingObjectPosition blah = Minecraft.getMinecraft().world.rayTraceBlocks(vec3, vec32, false, false, true);
|
RayTraceResult blah = Minecraft.getMinecraft().world.rayTraceBlocks(vec3, vec32, false, false, true);
|
||||||
return blah;
|
return blah;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean couldIReachByLookingAt(BlockPos pos, double x, double y, double z) {
|
public static boolean couldIReachByLookingAt(BlockPos pos, double x, double y, double z) {
|
||||||
MovingObjectPosition blah = raytraceTowards(x, y, z);
|
RayTraceResult blah = raytraceTowards(x, y, z);
|
||||||
return blah != null && blah.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && blah.getBlockPos().equals(pos);
|
return blah != null && blah.typeOfHit == RayTraceResult.Type.BLOCK && blah.getBlockPos().equals(pos);
|
||||||
}
|
}
|
||||||
public static Vec3 getVectorForRotation(float pitch, float yaw) {//shamelessly copied from Entity.java
|
|
||||||
|
public static Vec3d getVectorForRotation(float pitch, float yaw) {//shamelessly copied from Entity.java
|
||||||
float f = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
float f = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
||||||
float f1 = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI);
|
float f1 = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI);
|
||||||
float f2 = -MathHelper.cos(-pitch * 0.017453292F);
|
float f2 = -MathHelper.cos(-pitch * 0.017453292F);
|
||||||
float f3 = MathHelper.sin(-pitch * 0.017453292F);
|
float f3 = MathHelper.sin(-pitch * 0.017453292F);
|
||||||
return new Vec3((double) (f1 * f2), (double) f3, (double) (f * f2));
|
return new Vec3d((double) (f1 * f2), (double) f3, (double) (f * f2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GoalXZ fromAngleAndDirection(double distance) {
|
public static GoalXZ fromAngleAndDirection(double distance) {
|
||||||
double theta = ((double) Minecraft.getMinecraft().player.rotationYaw) * Math.PI / 180D;
|
double theta = ((double) Minecraft.getMinecraft().player.rotationYaw) * Math.PI / 180D;
|
||||||
double x = Minecraft.getMinecraft().player.posX - Math.sin(theta) * distance;
|
double x = Minecraft.getMinecraft().player.posX - Math.sin(theta) * distance;
|
||||||
double z = Minecraft.getMinecraft().player.posZ + Math.cos(theta) * distance;
|
double z = Minecraft.getMinecraft().player.posZ + Math.cos(theta) * distance;
|
||||||
return new GoalXZ((int) x, (int) z);
|
return new GoalXZ((int) x, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean lookingYaw() {
|
public static boolean lookingYaw() {
|
||||||
return lookingYaw;
|
return lookingYaw;
|
||||||
}
|
}
|
||||||
static double SPEED = 1000;
|
static double SPEED = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smoothly moves between random pitches and yaws every second
|
* Smoothly moves between random pitches and yaws every second
|
||||||
*
|
*
|
||||||
@ -202,19 +221,22 @@ public class LookManager extends Manager {
|
|||||||
float second = prevSecond + frac * (nowSecond - prevSecond);
|
float second = prevSecond + frac * (nowSecond - prevSecond);
|
||||||
return new float[]{first, second};
|
return new float[]{first, second};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float[] pitchAndYawToCenter(BlockPos p) {
|
public static float[] pitchAndYawToCenter(BlockPos p) {
|
||||||
Block b = Baritone.get(p).getBlock();
|
IBlockState b = Baritone.get(p);
|
||||||
double xDiff = (b.getBlockBoundsMinX() + b.getBlockBoundsMaxX()) / 2;
|
AxisAlignedBB bbox = b.getBoundingBox(Baritone.world, p);
|
||||||
double yolo = (b.getBlockBoundsMinY() + b.getBlockBoundsMaxY()) / 2;
|
double xDiff = (bbox.minX + bbox.maxX) / 2;
|
||||||
double zDiff = (b.getBlockBoundsMinZ() + b.getBlockBoundsMaxZ()) / 2;
|
double yDiff = (bbox.minY + bbox.maxY) / 2;
|
||||||
|
double zDiff = (bbox.minZ + bbox.maxZ) / 2;
|
||||||
if (b instanceof BlockFire) {//look at bottom of fire when putting it out
|
if (b instanceof BlockFire) {//look at bottom of fire when putting it out
|
||||||
yolo = 0;
|
yDiff = 0;
|
||||||
}
|
}
|
||||||
double x = p.getX() + xDiff;
|
double x = p.getX() + xDiff;
|
||||||
double y = p.getY() + yolo;
|
double y = p.getY() + yDiff;
|
||||||
double z = p.getZ() + zDiff;
|
double z = p.getZ() + zDiff;
|
||||||
return pitchAndYaw(x, y, z);
|
return pitchAndYaw(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float[] pitchAndYaw(double x, double y, double z) {
|
public static float[] pitchAndYaw(double x, double y, double z) {
|
||||||
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
||||||
double yDiff = (thePlayer.posY + 1.62) - y;//lol
|
double yDiff = (thePlayer.posY + 1.62) - y;//lol
|
||||||
@ -224,6 +246,7 @@ public class LookManager extends Manager {
|
|||||||
return new float[]{(float) (yaw * 180 / Math.PI), (float) (pitch * 180 / Math.PI)};
|
return new float[]{(float) (yaw * 180 / Math.PI), (float) (pitch * 180 / Math.PI)};
|
||||||
}
|
}
|
||||||
static ArrayList<Exception> sketchiness = new ArrayList<>();
|
static ArrayList<Exception> sketchiness = new ArrayList<>();
|
||||||
|
|
||||||
public static void setDesiredYaw(float y) {
|
public static void setDesiredYaw(float y) {
|
||||||
sketchiness.add(new Exception("Desired yaw already set!"));
|
sketchiness.add(new Exception("Desired yaw already set!"));
|
||||||
if (lookingYaw) {
|
if (lookingYaw) {
|
||||||
@ -236,6 +259,7 @@ public class LookManager extends Manager {
|
|||||||
desiredYaw = y;
|
desiredYaw = y;
|
||||||
lookingYaw = true;
|
lookingYaw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look at coordinates
|
* Look at coordinates
|
||||||
*
|
*
|
||||||
@ -264,6 +288,7 @@ public class LookManager extends Manager {
|
|||||||
}
|
}
|
||||||
return withinRange;
|
return withinRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTickPre() {
|
public void onTickPre() {
|
||||||
if (lookingYaw) {
|
if (lookingYaw) {
|
||||||
@ -276,6 +301,7 @@ public class LookManager extends Manager {
|
|||||||
sketchiness.clear();
|
sketchiness.clear();
|
||||||
lookingPitch = false;
|
lookingPitch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void nudgeToLevel() {
|
public static void nudgeToLevel() {
|
||||||
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
||||||
if (!lookingPitch) {
|
if (!lookingPitch) {
|
||||||
@ -286,6 +312,7 @@ public class LookManager extends Manager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTickPost() {
|
public void onTickPost() {
|
||||||
if (randomLooking) {
|
if (randomLooking) {
|
||||||
@ -329,15 +356,19 @@ public class LookManager extends Manager {
|
|||||||
desiredNextPitch = Minecraft.getMinecraft().player.rotationPitch - pitchDistance;
|
desiredNextPitch = Minecraft.getMinecraft().player.rotationPitch - pitchDistance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onTick() {
|
protected void onTick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCancel() {
|
protected void onCancel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onEnabled(boolean enabled) {
|
protected boolean onEnabled(boolean enabled) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user