cleanup
This commit is contained in:
parent
32427075c2
commit
4cb05a7979
@ -278,7 +278,7 @@ public class Baritone {
|
||||
}
|
||||
|
||||
public static boolean isAir(BlockPos pos) {
|
||||
return Minecraft.getMinecraft().world.getBlockState(pos).getBlock().equals(Block.getBlockById(0));
|
||||
return Baritone.get(pos).getBlock().equals(Block.getBlockById(0));
|
||||
}
|
||||
|
||||
public static void findPathInNewThread(final boolean talkAboutIt) {
|
||||
@ -392,7 +392,7 @@ public class Baritone {
|
||||
if (pos == null) {
|
||||
return;
|
||||
}
|
||||
Block block = Minecraft.getMinecraft().world.getBlockState(pos).getBlock();
|
||||
Block block = Baritone.get(pos).getBlock();
|
||||
if (block.equals(Block.getBlockById(0))) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,193 +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.inventory;
|
||||
|
||||
import baritone.ui.LookManager;
|
||||
import baritone.util.Memory;
|
||||
import java.util.ArrayList;
|
||||
import baritone.Baritone;
|
||||
import baritone.movement.MovementManager;
|
||||
import baritone.pathfinding.goals.GoalComposite;
|
||||
import baritone.pathfinding.goals.GoalGetToBlock;
|
||||
import baritone.util.Autorun;
|
||||
import baritone.util.ChatCommand;
|
||||
import baritone.util.ChatCommand;
|
||||
import baritone.util.Manager;
|
||||
import baritone.util.Manager;
|
||||
import baritone.util.Memory;
|
||||
import baritone.util.Out;
|
||||
import baritone.util.Out;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.inventory.GuiChest;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author avecowa
|
||||
*/
|
||||
public class AnotherStealer extends Manager {
|
||||
protected static Manager newInstance() {
|
||||
return null;
|
||||
}
|
||||
public static ArrayList<BlockPos> alreadyStolenFrom = new ArrayList<BlockPos>();
|
||||
public static boolean chestStuff = false;
|
||||
public static boolean stuff = false;
|
||||
public static BlockPos current = null;
|
||||
private static final Block CHEST = Block.getBlockFromName("chest");
|
||||
private static boolean positionArmor = false;
|
||||
private static int positionSlot = 0;
|
||||
private static int positionStatus = 0;
|
||||
@Override
|
||||
public void onTick() {
|
||||
//try{
|
||||
if (invFull()) {
|
||||
ChatCommand.stealer("stealer");
|
||||
return;
|
||||
}
|
||||
if (Baritone.isThereAnythingInProgress || Baritone.currentPath != null) {
|
||||
Out.log(Baritone.currentPath);
|
||||
return;
|
||||
}
|
||||
if (stuff) {
|
||||
stuff = false;
|
||||
ArrayList<BlockPos> chests = Memory.closest(100, "chest");
|
||||
chests.removeAll(alreadyStolenFrom);
|
||||
if (chests.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
BlockPos[] goals = GoalGetToBlock.ajacentBlocks(chests.get(0));
|
||||
for (int i = 1; i < chests.size(); i++) {
|
||||
goals = Autorun.concat(goals, GoalGetToBlock.ajacentBlocks(chests.get(i)));
|
||||
}
|
||||
Baritone.goal = new GoalComposite(goals);
|
||||
ChatCommand.path("path false");
|
||||
return;
|
||||
}
|
||||
if (positionArmor) {
|
||||
if (!(Minecraft.getMinecraft().currentScreen instanceof GuiInventory)) {
|
||||
Out.gui("BAD GUI", Out.Mode.Debug);
|
||||
positionArmor = false;
|
||||
return;
|
||||
}
|
||||
Out.gui("Position Armor:" + positionSlot, Out.Mode.Debug);
|
||||
if (positionStatus == 0) {
|
||||
Container inv = Minecraft.getMinecraft().player.inventoryContainer;
|
||||
Out.gui("Position Status 0:" + inv.inventorySlots.size(), Out.Mode.Debug);
|
||||
for (int i = positionSlot; i < 45; i++) {
|
||||
Out.gui((inv.getSlot(i).getHasStack() ? inv.getSlot(i).getStack().getItem().toString() : "NULL STACK") + " :" + i, Out.Mode.Debug);
|
||||
if (inv.getSlot(i).getHasStack() && inv.getSlot(i).getStack().getItem() instanceof ItemArmor) {
|
||||
Out.gui("ITEM IS ARMOR", Out.Mode.Debug);
|
||||
ItemArmor armor = (ItemArmor) inv.getSlot(i).getStack().getItem();
|
||||
if (inv.getSlot(armor.armorType).getHasStack() && ((ItemArmor) inv.getSlot(armor.armorType).getStack().getItem()).damageReduceAmount < armor.damageReduceAmount) {
|
||||
positionSlot = i;
|
||||
positionStatus = 1;
|
||||
Minecraft.getMinecraft().playerController.windowClick(((GuiContainer) Minecraft.getMinecraft().currentScreen).inventorySlots.windowId, 103 - armor.armorType, 0, 1, Minecraft.getMinecraft().player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
positionArmor = false;
|
||||
Minecraft.getMinecraft().player.closeScreen();
|
||||
return;
|
||||
}
|
||||
if (positionStatus == 1) {
|
||||
Minecraft.getMinecraft().playerController.windowClick(((GuiContainer) Minecraft.getMinecraft().currentScreen).inventorySlots.windowId, positionSlot, 0, 1, Minecraft.getMinecraft().player);
|
||||
positionStatus = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
BlockPos near = getAjacentChest();
|
||||
if (near == null) {
|
||||
stuff = true;
|
||||
return;
|
||||
}
|
||||
if (near.equals(Baritone.whatAreYouLookingAt())) {
|
||||
if (chestStuff) {
|
||||
Out.gui("CHEST STUFF", Out.Mode.Debug);
|
||||
EntityPlayerSP player = Minecraft.getMinecraft().player;
|
||||
WorldClient world = Minecraft.getMinecraft().world;
|
||||
if (Minecraft.getMinecraft().currentScreen == null) {
|
||||
chestStuff = false;
|
||||
Out.gui("NULL GUI", Out.Mode.Debug);
|
||||
return;
|
||||
}
|
||||
if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
|
||||
Out.gui("NOT CHEST GUI", Out.Mode.Debug);
|
||||
return;
|
||||
}
|
||||
GuiChest contain = (GuiChest) Minecraft.getMinecraft().currentScreen;
|
||||
Slot slot = getFilledSlot(contain);
|
||||
Out.gui(slot == null ? "null slot" : slot.getHasStack() ? slot.getStack().getItem().toString() : "empty slot", Out.Mode.Debug);
|
||||
if (slot == null) {
|
||||
Out.gui("CLOSING THE SCREEN", Out.Mode.Debug);
|
||||
alreadyStolenFrom.add(near);
|
||||
positionArmor = true;
|
||||
positionSlot = 9;
|
||||
positionStatus = 0;
|
||||
Baritone.slowOpenInventory();
|
||||
return;
|
||||
}
|
||||
contain.shiftClick(slot.slotNumber);
|
||||
return;
|
||||
}
|
||||
Out.gui("NO CHEST STUFF", Out.Mode.Debug);
|
||||
chestStuff = true;
|
||||
MovementManager.isRightClick = true;
|
||||
current = Baritone.whatAreYouLookingAt();
|
||||
return;
|
||||
}
|
||||
LookManager.lookAtBlock(near, true);
|
||||
return;
|
||||
}
|
||||
public static BlockPos getAjacentChest() {
|
||||
BlockPos[] pos = GoalGetToBlock.ajacentBlocks(Baritone.playerFeet);
|
||||
WorldClient w = Minecraft.getMinecraft().world;
|
||||
for (BlockPos p : pos) {
|
||||
if (!alreadyStolenFrom.contains(p) && w.getBlockState(p).getBlock().equals(CHEST)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static Slot getFilledSlot(GuiChest chest) {
|
||||
for (int i = 0; i < chest.lowerChestInventory.getSizeInventory(); i++) {
|
||||
if (chest.lowerChestInventory.getStackInSlot(i) != null) {
|
||||
return chest.inventorySlots.getSlotFromInventory(chest.lowerChestInventory, i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static boolean invFull() {
|
||||
ItemStack[] inv = Minecraft.getMinecraft().player.inventory.mainInventory;
|
||||
for (ItemStack i : inv) {
|
||||
if (i == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void onCancel() {
|
||||
}
|
||||
@Override
|
||||
protected void onStart() {
|
||||
alreadyStolenFrom = new ArrayList<BlockPos>();
|
||||
chestStuff = false;
|
||||
stuff = false;
|
||||
current = null;
|
||||
positionArmor = false;
|
||||
positionSlot = 0;
|
||||
}
|
||||
}
|
@ -1,694 +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.inventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import baritone.inventory.InventoryManager;
|
||||
import baritone.ui.LookManager;
|
||||
import baritone.util.Memory;
|
||||
import baritone.Baritone;
|
||||
import baritone.movement.MovementManager;
|
||||
import baritone.mining.MickeyMine;
|
||||
import baritone.pathfinding.goals.GoalBlock;
|
||||
import baritone.pathfinding.goals.GoalComposite;
|
||||
import baritone.util.Manager;
|
||||
import baritone.util.ManagerTick;
|
||||
import baritone.util.Out;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiCrafting;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author galdara
|
||||
*/
|
||||
public class CraftingTask extends ManagerTick {
|
||||
static ArrayList<CraftingTask> overallCraftingTasks = new ArrayList<CraftingTask>();
|
||||
ArrayList<CraftingTask> subCraftingTasks = new ArrayList<CraftingTask>();
|
||||
private Item currentlyCrafting = null;
|
||||
private int stackSize;
|
||||
private int alreadyHas;
|
||||
private CraftingTask(ItemStack craftStack) {
|
||||
this.currentlyCrafting = craftStack.getItem();
|
||||
this.stackSize = 0;
|
||||
buildTasks();
|
||||
increaseNeededAmount(craftStack.stackSize);
|
||||
}
|
||||
public static int map(int id, int width, int height, int craftingSize) {//shamelessly copied from Objectives
|
||||
int yPos = id / width;
|
||||
int xPos = id % width;
|
||||
int z = xPos + craftingSize * yPos;
|
||||
return z + 1;
|
||||
}
|
||||
/**
|
||||
* @param item
|
||||
* @return recipe for that item, or null if item has no recipe
|
||||
*/
|
||||
public static IRecipe getRecipeFromItem(Item item) {
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
for (IRecipe currRecipe : recipes) {
|
||||
if (currRecipe == null) {
|
||||
continue;
|
||||
}
|
||||
if (currRecipe.getRecipeOutput() == null) {
|
||||
continue;
|
||||
}
|
||||
if (currRecipe.getRecipeOutput().getItem() == null) {
|
||||
continue;//probably not all of these are necessary, but when I added all three it stopped a nullpointerexception somewhere in this function
|
||||
}
|
||||
if (currRecipe.getRecipeOutput().getItem().equals(item)) {
|
||||
if (isRecipeOkay(currRecipe)) {
|
||||
return currRecipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static boolean isRecipeOkay(IRecipe recipe) {
|
||||
if (recipe instanceof ShapedRecipes) {
|
||||
if (((ShapedRecipes) recipe).recipeItems.length > 1) {
|
||||
return true;
|
||||
}
|
||||
for (ItemStack stack : ((ShapedRecipes) recipe).recipeItems) {
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
if (stack.toString().toLowerCase().contains("block")) {
|
||||
Out.log("Not doing " + stack);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (recipe instanceof ShapelessRecipes) {
|
||||
if (((ShapelessRecipes) recipe).recipeItems.size() > 1) {
|
||||
return true;
|
||||
}
|
||||
for (ItemStack stack : ((ShapelessRecipes) recipe).recipeItems) {
|
||||
if (stack.toString().toLowerCase().contains("block")) {
|
||||
Out.log("Not doing " + stack);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean recipeNeedsCraftingTable(IRecipe recipe) {
|
||||
return (recipe instanceof ShapelessRecipes && recipe.getRecipeSize() > 4) || (recipe instanceof ShapedRecipes && (((ShapedRecipes) recipe).recipeHeight > 2 || ((ShapedRecipes) recipe).recipeWidth > 2));
|
||||
}
|
||||
ArrayList<int[]> plan = null;
|
||||
int tickNumber = 0;
|
||||
static int ticksBetweenClicks = 4;
|
||||
public void tickPlan() {
|
||||
GuiContainer contain = (GuiContainer) Minecraft.getMinecraft().currentScreen;
|
||||
if (tickNumber % ticksBetweenClicks == 0) {
|
||||
int index = tickNumber / ticksBetweenClicks;
|
||||
if (index >= plan.size()) {
|
||||
Out.gui("Plan over", Out.Mode.Debug);
|
||||
plan = null;
|
||||
tickNumber = -40;
|
||||
return;
|
||||
}
|
||||
if (index >= 0) {
|
||||
int[] click = plan.get(index);
|
||||
Out.gui(index + " " + click[0] + " " + click[1] + " " + click[2] + " " + currentlyCrafting(), Out.Mode.Debug);
|
||||
contain.sketchyMouseClick(click[0], click[1], click[2]);
|
||||
Out.log("Ticking plan");
|
||||
}
|
||||
}
|
||||
tickNumber++;
|
||||
}
|
||||
public boolean onTick1() {
|
||||
if (plan != null) {
|
||||
if (Minecraft.getMinecraft().currentScreen == null || !(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
|
||||
plan = null;
|
||||
tickNumber = 0;
|
||||
return true;
|
||||
}
|
||||
tickPlan();
|
||||
return true;
|
||||
}
|
||||
if (isDone()) {
|
||||
return false;
|
||||
}
|
||||
if (stackSize != 0) {
|
||||
Out.log(currentlyCrafting() + " " + alreadyHas + " " + isDone());
|
||||
}
|
||||
boolean hasMaterials = actualDoCraft(1, false, true) != null;
|
||||
//Out.log("materials " + this + " " + currentlyCrafting() + " " + hasMaterials);
|
||||
if (!hasMaterials) {
|
||||
return false;
|
||||
}
|
||||
boolean isCraftingTable = Minecraft.getMinecraft().currentScreen != null && Minecraft.getMinecraft().currentScreen instanceof GuiCrafting;
|
||||
if (isCraftingTable) {
|
||||
findOrCreateCraftingTask(new ItemStack(Item.getByNameOrId("minecraft:crafting_table"), 0)).clearAll();
|
||||
}
|
||||
if (!recipeNeedsCraftingTable(getRecipeFromItem(currentlyCrafting)) && !isCraftingTable) {
|
||||
craftAsManyAsICan(true);
|
||||
return true;//if this doesn't need a crafting table, return no matter what
|
||||
}
|
||||
//at this point we know that we need a crafting table
|
||||
if (isCraftingTable) {
|
||||
craftAsManyAsICan(false);
|
||||
return true;//since we are already in a crafting table, return so we don't run the code to get into a crafting table repeatedly
|
||||
}
|
||||
if (!recipeNeedsCraftingTable(getRecipeFromItem(currentlyCrafting))) {
|
||||
return false;
|
||||
}
|
||||
//at this point we know that we need a crafting table and we aren't in one at this moment
|
||||
BlockPos craftingTableLocation = Memory.closestOne("crafting_table");
|
||||
if (craftingTableLocation != null) {
|
||||
MickeyMine.tempDisable = true;
|
||||
if (LookManager.couldIReach(craftingTableLocation)) {
|
||||
LookManager.lookAtBlock(craftingTableLocation, true);
|
||||
if (craftingTableLocation.equals(Baritone.whatAreYouLookingAt())) {
|
||||
Baritone.currentPath = null;
|
||||
MovementManager.clearMovement();
|
||||
Minecraft.getMinecraft().rightClickMouse();
|
||||
findOrCreateCraftingTask(new ItemStack(Item.getByNameOrId("minecraft:crafting_table"), 0)).clearAll();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
double diffX = craftingTableLocation.getX() + 0.5D - Minecraft.getMinecraft().player.posX;
|
||||
double diffY = craftingTableLocation.getY() + 0.5D - Minecraft.getMinecraft().player.posY;
|
||||
double diffZ = craftingTableLocation.getZ() + 0.5D - Minecraft.getMinecraft().player.posZ;
|
||||
double distXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
|
||||
if (distXZ < 50 && Math.abs(diffY) < 20) {
|
||||
Baritone.goal = new GoalComposite(new GoalBlock(craftingTableLocation.up()), new GoalBlock(craftingTableLocation.north()), new GoalBlock(craftingTableLocation.south()), new GoalBlock(craftingTableLocation.east()), new GoalBlock(craftingTableLocation.west()), new GoalBlock(craftingTableLocation.north().down()), new GoalBlock(craftingTableLocation.south().down()), new GoalBlock(craftingTableLocation.east().down()), new GoalBlock(craftingTableLocation.west().down()));
|
||||
if (Baritone.currentPath == null && !Baritone.isPathFinding()) {
|
||||
Baritone.findPathInNewThread(false);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
Out.gui("too far away from closest crafting table (" + distXZ + " blocks), crafting another", Out.Mode.Debug);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Baritone.whatAreYouLookingAt() != null && Block.getBlockFromName("crafting_table").equals(Minecraft.getMinecraft().world.getBlockState(Baritone.whatAreYouLookingAt()).getBlock())) {
|
||||
Baritone.currentPath = null;
|
||||
MovementManager.clearMovement();
|
||||
Minecraft.getMinecraft().rightClickMouse();
|
||||
findOrCreateCraftingTask(new ItemStack(Item.getByNameOrId("minecraft:crafting_table"), 0)).clearAll();
|
||||
return true;
|
||||
}
|
||||
//at this point we know that we need a crafting table and we aren't in one and there isn't one nearby
|
||||
if (putCraftingTableOnHotBar()) {
|
||||
MickeyMine.tempDisable = true;
|
||||
findOrCreateCraftingTask(new ItemStack(Item.getByNameOrId("minecraft:crafting_table"), 0)).clearAll();
|
||||
Out.log("Ready to place!");
|
||||
if (placeHeldBlockNearby()) {
|
||||
return true;
|
||||
}
|
||||
BlockPos player = Baritone.playerFeet;
|
||||
if (Baritone.isAir(player.down()) || Baritone.isAir(player.up(2))) {
|
||||
Out.gui("Placing down", Out.Mode.Debug);
|
||||
LookManager.lookAtBlock(Baritone.playerFeet.down(), true);
|
||||
MovementManager.jumping = true;
|
||||
MovementManager.sneak = true;
|
||||
if (Baritone.playerFeet.down().equals(Baritone.whatAreYouLookingAt()) || Baritone.playerFeet.down().down().equals(Baritone.whatAreYouLookingAt())) {
|
||||
Minecraft.getMinecraft().rightClickMouse();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
LookManager.lookAtBlock(Baritone.playerFeet.down().north(), true);
|
||||
LookManager.beSketchy();
|
||||
Baritone.forward = new Random().nextBoolean();
|
||||
Baritone.backward = new Random().nextBoolean();
|
||||
Baritone.left = new Random().nextBoolean();
|
||||
Baritone.right = new Random().nextBoolean();
|
||||
Baritone.jumping = true;*/
|
||||
return true;
|
||||
} else if (hasCraftingTableInInventory()) {
|
||||
InventoryManager.putOnHotBar(Item.getByNameOrId("crafting_table"));
|
||||
return true;
|
||||
}
|
||||
//at this point we know that we need a crafting table and we aren't in one and there isn't one nearby and we don't have one
|
||||
ensureCraftingDesired(Item.getByNameOrId("crafting_table"), 1);
|
||||
//at this point we know that we need a crafting table and we aren't in one and there isn't one nearby and we don't have one and we don't have the materials to make one
|
||||
//so just rip at this point
|
||||
return false;
|
||||
}
|
||||
public static boolean placeHeldBlockNearby() {
|
||||
BlockPos player = Baritone.playerFeet;
|
||||
for (int x = player.getX() - 3; x <= player.getX() + 3; x++) {
|
||||
for (int y = player.getY() - 2; y <= player.getY() + 1; y++) {
|
||||
for (int z = player.getZ() - 3; z <= player.getZ() + 3; z++) {
|
||||
if (x == player.getX() && z == player.getZ()) {
|
||||
continue;
|
||||
}
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
if (Minecraft.getMinecraft().world.getBlockState(pos).getBlock().equals(Block.getBlockFromName("crafting_table"))) {
|
||||
Memory.scanBlock(pos);
|
||||
}
|
||||
if (Baritone.isAir(pos)) {
|
||||
for (EnumFacing f : EnumFacing.values()) {
|
||||
BlockPos placeAgainst = pos.offset(f);
|
||||
if (!Baritone.isAir(placeAgainst) && Minecraft.getMinecraft().world.getBlockState(placeAgainst).getBlock().isBlockNormalCube()) {
|
||||
if (LookManager.couldIReach(placeAgainst, f.getOpposite())) {
|
||||
MovementManager.sneak = true;
|
||||
double faceX = (pos.getX() + placeAgainst.getX() + 1.0D) * 0.5D;
|
||||
double faceY = (pos.getY() + placeAgainst.getY()) * 0.5D;
|
||||
double faceZ = (pos.getZ() + placeAgainst.getZ() + 1.0D) * 0.5D;
|
||||
if (LookManager.lookAtCoords(faceX, faceY, faceZ, true) && Minecraft.getMinecraft().player.isSneaking()) {
|
||||
Minecraft.getMinecraft().rightClickMouse();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean hasCraftingTableInInventory() {
|
||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||
ItemStack[] inv = p.inventory.mainInventory;
|
||||
for (ItemStack item : inv) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if (Item.getByNameOrId("minecraft:crafting_table").equals(item.getItem())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean putCraftingTableOnHotBar() {//shamelessly copied from MickeyMine.torch()
|
||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||
ItemStack[] inv = p.inventory.mainInventory;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack item = inv[i];
|
||||
if (inv[i] == null) {
|
||||
continue;
|
||||
}
|
||||
if (Item.getByNameOrId("minecraft:crafting_table").equals(item.getItem())) {
|
||||
p.inventory.currentItem = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void clearAll() {
|
||||
if (stackSize != 0) {
|
||||
decreaseNeededAmount(stackSize);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param inInventory
|
||||
* @return did I actually craft some
|
||||
*/
|
||||
public boolean craftAsManyAsICan(boolean inInventory) {
|
||||
int amtCurrentlyCraftable = stackSize - alreadyHas;
|
||||
if (amtCurrentlyCraftable > 64) {
|
||||
amtCurrentlyCraftable = 64;
|
||||
}
|
||||
while (true) {
|
||||
Boolean b = actualDoCraft(amtCurrentlyCraftable, inInventory, false);
|
||||
if (b != null) {
|
||||
return b;
|
||||
}
|
||||
amtCurrentlyCraftable--;
|
||||
if (amtCurrentlyCraftable <= 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param outputQuantity
|
||||
* @param inInventory
|
||||
* @param justChecking
|
||||
* @return true if it was able to craft and did, null if it was unable to
|
||||
* craft because of a lack of input items, false for anything else
|
||||
* (including being unable to craft for other reasons)
|
||||
*/
|
||||
public Boolean actualDoCraft(int outputQuantity, boolean inInventory, boolean justChecking) {
|
||||
IRecipe currentRecipe = getRecipeFromItem(currentlyCrafting);
|
||||
int outputVolume = currentRecipe.getRecipeOutput().stackSize;
|
||||
int inputQuantity = (int) Math.ceil(((double) outputQuantity) / (outputVolume));
|
||||
if (currentRecipe instanceof ShapedRecipes) {
|
||||
ShapedRecipes shaped = (ShapedRecipes) currentRecipe;
|
||||
if (!inInventory || (inInventory && shaped.recipeHeight <= 2 && shaped.recipeWidth <= 2)) {
|
||||
int numNotNull = 0;
|
||||
for (ItemStack recipeItem : shaped.recipeItems) {
|
||||
if (recipeItem != null) {
|
||||
numNotNull++;
|
||||
}
|
||||
}
|
||||
Item[] items = new Item[numNotNull];
|
||||
int[] positions = new int[items.length];
|
||||
int index = 0;
|
||||
for (int i = 0; i < shaped.recipeItems.length; i++) {
|
||||
if (shaped.recipeItems[i] == null) {
|
||||
continue;
|
||||
}
|
||||
items[index] = shaped.recipeItems[i].getItem();
|
||||
positions[index] = map(i, shaped.recipeWidth, shaped.recipeHeight, inInventory ? 2 : 3);
|
||||
index++;
|
||||
}
|
||||
return actualDoCraftOne(items, positions, inputQuantity, inInventory, justChecking);
|
||||
}
|
||||
}
|
||||
if (currentRecipe instanceof ShapelessRecipes) {
|
||||
ShapelessRecipes shapeless = (ShapelessRecipes) currentRecipe;
|
||||
if (!inInventory || (inInventory && shapeless.getRecipeSize() < 4)) {
|
||||
Item[] items = new Item[shapeless.getRecipeSize()];
|
||||
int[] positions = new int[items.length];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = shapeless.recipeItems.get(i).getItem();
|
||||
positions[i] = i + 1;
|
||||
}
|
||||
return actualDoCraftOne(items, positions, inputQuantity, inInventory, justChecking);
|
||||
}
|
||||
}
|
||||
return justChecking ? null : false;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param items
|
||||
* @param positions
|
||||
* @param amount
|
||||
* @param inv
|
||||
* @param justChecking
|
||||
* @return true if it was able to craft and did, null if it was unable to
|
||||
* craft because of a lack of input items, false for anything else
|
||||
* (including being unable to craft for other reasons)
|
||||
*/
|
||||
public Boolean actualDoCraftOne(Item[] items, int[] positions, int amount, boolean inv, boolean justChecking) {
|
||||
int[] amounts = new int[items.length];
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
amounts[i] = amount;
|
||||
}
|
||||
int[] count = new int[items.length];
|
||||
for (ItemStack in : Minecraft.getMinecraft().player.inventory.mainInventory) {
|
||||
if (in == null) {
|
||||
continue;
|
||||
}
|
||||
Item item = in.getItem();
|
||||
int size = in.stackSize;
|
||||
for (int j = 0; j < items.length; j++) {
|
||||
if (items[j].equals(item)) {
|
||||
int amountRemain = amounts[j] - count[j];
|
||||
if (amountRemain >= size) {
|
||||
count[j] += size;
|
||||
size = 0;
|
||||
} else {
|
||||
count[j] += amountRemain;
|
||||
size -= amountRemain;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < count.length; i++) {
|
||||
if (count[i] != amounts[i]) {
|
||||
//Out.gui("Not enough " + items[i], true);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (justChecking) {
|
||||
return false;
|
||||
}
|
||||
if (inv) {
|
||||
if (Minecraft.getMinecraft().currentScreen == null || !(Minecraft.getMinecraft().currentScreen instanceof GuiInventory)) {
|
||||
Out.log("Opening");
|
||||
Baritone.slowOpenInventory();
|
||||
}
|
||||
didIOpenMyInventory = true;
|
||||
} else if (Minecraft.getMinecraft().currentScreen == null || !(Minecraft.getMinecraft().currentScreen instanceof GuiCrafting)) {
|
||||
Out.gui("Not in crafting table", Out.Mode.Debug);
|
||||
return false;
|
||||
} else {
|
||||
didIOpenMyInventory = true;
|
||||
}
|
||||
GuiContainer contain = (GuiContainer) Minecraft.getMinecraft().currentScreen;
|
||||
for (int i = 1; i < (inv ? 5 : 10); i++) {
|
||||
if (contain.inventorySlots.inventorySlots.get(i).getHasStack()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Out.gui("Crafting amount " + amount + " of " + currentlyCrafting(), Out.Mode.Debug);
|
||||
plan = new ArrayList();
|
||||
tickNumber = -10;
|
||||
for (int i = inv ? 9 : 10; i < contain.inventorySlots.inventorySlots.size(); i++) {
|
||||
Slot slot = contain.inventorySlots.inventorySlots.get(i);
|
||||
if (!slot.getHasStack()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack in = slot.getStack();
|
||||
if (in == null) {
|
||||
continue;
|
||||
}
|
||||
Item item = in.getItem();
|
||||
int size = in.stackSize;
|
||||
for (int j = 0; j < items.length; j++) {
|
||||
if (amounts[j] <= 0) {
|
||||
continue;
|
||||
}
|
||||
if (items[j].equals(item)) {
|
||||
leftClick(i);
|
||||
if (size <= amounts[j]) {
|
||||
leftClick(positions[j]);
|
||||
amounts[j] -= size;
|
||||
size = 0;
|
||||
} else {
|
||||
for (int k = 0; k < amounts[j]; k++) {
|
||||
rightClick(positions[j]);
|
||||
}
|
||||
size -= amounts[j];
|
||||
leftClick(i);
|
||||
amounts[j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Out.gui("shift clicking " + contain.inventorySlots.inventorySlots.get(0).getStack(), Out.Mode.Debug);
|
||||
shiftClick(0);
|
||||
for (int i = 0; i < amounts.length; i++) {
|
||||
if (amounts[i] > 0) {
|
||||
Out.gui("Not enough " + i + " " + amounts[i] + " " + items[i] + " " + positions[i], Out.Mode.Debug);//this detects if it didn't have enough, but you shouldn't call this function unless you have already made sure you have enough
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void leftClick(int slot) {
|
||||
if (!plan.isEmpty()) {
|
||||
int[] last = plan.get(plan.size() - 1);
|
||||
if (last[0] == slot && last[1] == 0 && last[2] == 0) {
|
||||
plan.remove(plan.size() - 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
plan.add(new int[]{slot, 0, 0});
|
||||
}
|
||||
public void rightClick(int slot) {
|
||||
plan.add(new int[]{slot, 1, 0});
|
||||
}
|
||||
public void shiftClick(int slot) {
|
||||
plan.add(new int[]{slot, 0, 1});
|
||||
}
|
||||
static boolean didIOpenMyInventory = false;
|
||||
static boolean waitingToClose = false;
|
||||
static int TUC = 20;
|
||||
@Override
|
||||
protected boolean onTick0() {
|
||||
for (CraftingTask craftingTask : overallCraftingTasks) {
|
||||
if (craftingTask.plan != null) {
|
||||
Out.log(craftingTask + " " + craftingTask.currentlyCrafting() + " " + craftingTask.plan);
|
||||
if (!craftingTask.onTick1()) {
|
||||
didIOpenMyInventory = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (CraftingTask craftingTask : overallCraftingTasks) {
|
||||
if (craftingTask.onTick1()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (didIOpenMyInventory) {
|
||||
waitingToClose = true;
|
||||
TUC = 3;
|
||||
didIOpenMyInventory = false;
|
||||
}
|
||||
if (waitingToClose) {
|
||||
TUC--;
|
||||
if (TUC <= 0) {
|
||||
Out.gui("Closing screen!!!", Out.Mode.Debug);
|
||||
Minecraft.getMinecraft().player.closeScreen();
|
||||
waitingToClose = false;
|
||||
TUC = 3;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public final void buildTasks() {
|
||||
IRecipe currentRecipe = getRecipeFromItem(currentlyCrafting);
|
||||
if (!(currentRecipe == null)) {
|
||||
if (currentRecipe instanceof ShapedRecipes) {
|
||||
ShapedRecipes shapedRecipe = (ShapedRecipes) currentRecipe;
|
||||
for (ItemStack input : shapedRecipe.recipeItems) {
|
||||
if (input == null) {
|
||||
continue;
|
||||
}
|
||||
IRecipe inputRecipe = getRecipeFromItem(input.getItem());
|
||||
if (!(inputRecipe == null)) {
|
||||
Out.log("As a part of " + currentlyCrafting + ", getting " + input);
|
||||
CraftingTask newTask = CraftingTask.findOrCreateCraftingTask(new ItemStack(input.getItem(), 0));
|
||||
subCraftingTasks.add(newTask);
|
||||
//newTask.execute();
|
||||
}
|
||||
}
|
||||
} else if (currentRecipe instanceof ShapelessRecipes) {
|
||||
ShapelessRecipes shapelessRecipe = (ShapelessRecipes) currentRecipe;
|
||||
for (ItemStack input : shapelessRecipe.recipeItems) {
|
||||
IRecipe inputRecipe = getRecipeFromItem(input.getItem());
|
||||
if (!(inputRecipe == null)) {
|
||||
Out.log("As a part of " + currentlyCrafting + ", getting " + input);
|
||||
CraftingTask newTask = CraftingTask.findOrCreateCraftingTask(new ItemStack(input.getItem(), 0));
|
||||
subCraftingTasks.add(newTask);
|
||||
//newTask.execute();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Current recipe isn't shapeless or shaped");
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("no recipe for this");
|
||||
}
|
||||
}
|
||||
public static CraftingTask findOrCreateCraftingTask(ItemStack itemStack) {
|
||||
//Out.log("Getting a task for " + itemStack);
|
||||
for (CraftingTask selectedTask : overallCraftingTasks) {
|
||||
if (selectedTask.currentlyCrafting().getItem().equals(itemStack.getItem())) {
|
||||
if (itemStack.stackSize != 0) {
|
||||
selectedTask.increaseNeededAmount(itemStack.stackSize);
|
||||
}
|
||||
return selectedTask;
|
||||
}
|
||||
}
|
||||
CraftingTask newTask = new CraftingTask(itemStack);
|
||||
overallCraftingTasks.add(newTask);
|
||||
return newTask;
|
||||
}
|
||||
public ItemStack currentlyCrafting() {
|
||||
return new ItemStack(currentlyCrafting, stackSize);
|
||||
}
|
||||
public final void increaseNeededAmount(int amount) {
|
||||
//Out.gui(currentlyCrafting() + " inc " + amount);
|
||||
int stackSizeBefore = stackSize;
|
||||
stackSize += amount;
|
||||
IRecipe currentRecipe = getRecipeFromItem(currentlyCrafting);
|
||||
int outputVolume = currentRecipe.getRecipeOutput().stackSize;
|
||||
int inputQuantityBefore = (int) Math.ceil(((double) stackSizeBefore) / outputVolume);
|
||||
int inputQuantityNew = (int) Math.ceil(((double) stackSize) / outputVolume);
|
||||
int change = inputQuantityNew - inputQuantityBefore;
|
||||
if (change != 0) {
|
||||
/*for (CraftingTask craftingTask : subCraftingTasks) {
|
||||
Out.gui("> inc sub " + craftingTask.currentlyCrafting() + " " + change);
|
||||
}*/
|
||||
for (CraftingTask craftingTask : subCraftingTasks) {
|
||||
craftingTask.increaseNeededAmount(change);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void decreaseNeededAmount(int amount) {
|
||||
//Out.gui(currentlyCrafting() + " dec " + amount);
|
||||
int stackSizeBefore = stackSize;
|
||||
stackSize -= amount;
|
||||
IRecipe currentRecipe = getRecipeFromItem(currentlyCrafting);
|
||||
int outputVolume = currentRecipe.getRecipeOutput().stackSize;
|
||||
int inputQuantityBefore = (int) Math.ceil(((double) stackSizeBefore) / (outputVolume));
|
||||
int inputQuantityNew = (int) Math.ceil(((double) stackSize) / outputVolume);
|
||||
int change = inputQuantityBefore - inputQuantityNew;
|
||||
if (change != 0) {
|
||||
/*for (CraftingTask craftingTask : subCraftingTasks) {
|
||||
Out.gui("> dec sub " + craftingTask.currentlyCrafting() + " " + change);
|
||||
}*/
|
||||
for (CraftingTask craftingTask : subCraftingTasks) {
|
||||
craftingTask.decreaseNeededAmount(change);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void calculateAlreadyHasAmount() {
|
||||
int count = 0;
|
||||
for (ItemStack armor : Minecraft.getMinecraft().player.inventory.armorInventory) {
|
||||
if (armor == null) {
|
||||
continue;
|
||||
}
|
||||
if (currentlyCrafting.equals(armor.getItem())) {
|
||||
count += armor.stackSize;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < Minecraft.getMinecraft().player.inventory.getSizeInventory(); i++) {
|
||||
if (Minecraft.getMinecraft().player.inventory.getStackInSlot(i) == null) {
|
||||
continue;
|
||||
}
|
||||
if (Minecraft.getMinecraft().player.inventory.getStackInSlot(i).getItem().equals(currentlyCrafting)) {
|
||||
count += Minecraft.getMinecraft().player.inventory.getStackInSlot(i).stackSize;
|
||||
}
|
||||
}
|
||||
alreadyHas = count;
|
||||
}
|
||||
public int alreadyHas() {
|
||||
return alreadyHas;
|
||||
}
|
||||
public boolean isDone() {
|
||||
calculateAlreadyHasAmount();
|
||||
return stackSize <= alreadyHas;
|
||||
}
|
||||
public static boolean ensureCraftingDesired(Item item, int quantity) {
|
||||
if (item == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
CraftingTask craftingTableTask = CraftingTask.findOrCreateCraftingTask(new ItemStack(item, 0));
|
||||
//Out.log(craftingTableTask.currentlyCrafting() + " " + quantity + " " + craftingTableTask.stackSize + " " + craftingTableTask.alreadyHas + " " + craftingTableTask.isDone());
|
||||
if (craftingTableTask.isDone() && craftingTableTask.alreadyHas >= quantity) {
|
||||
if (craftingTableTask.stackSize > 0) {
|
||||
craftingTableTask.decreaseNeededAmount(1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (craftingTableTask.stackSize < quantity) {
|
||||
craftingTableTask.increaseNeededAmount(quantity - craftingTableTask.stackSize);
|
||||
}
|
||||
return craftingTableTask.alreadyHas >= quantity;
|
||||
}
|
||||
public static Manager createInstance(Class c) {
|
||||
return new CraftingTask();
|
||||
}
|
||||
private CraftingTask() {
|
||||
}
|
||||
@Override
|
||||
protected void onCancel() {
|
||||
overallCraftingTasks.clear();
|
||||
}
|
||||
@Override
|
||||
protected void onStart() {
|
||||
}
|
||||
@Override
|
||||
protected boolean onEnabled(boolean enabled) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,74 +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.inventory;
|
||||
|
||||
import baritone.movement.MovementManager;
|
||||
import static baritone.Baritone.whatAreYouLookingAt;
|
||||
import baritone.util.ManagerTick;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.FoodStats;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public class FoodManager extends ManagerTick {
|
||||
@Override
|
||||
protected boolean onTick0() {
|
||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||
FoodStats fs = p.getFoodStats();
|
||||
if (!fs.needFood()) {
|
||||
return false;
|
||||
}
|
||||
int foodNeeded = 20 - fs.getFoodLevel();
|
||||
boolean anything = foodNeeded >= 3 && Minecraft.getMinecraft().player.getHealth() < 20;//if this is true, we'll just eat anything to get our health up
|
||||
ItemStack[] inv = p.inventory.mainInventory;
|
||||
byte slotForFood = -1;
|
||||
int worst = 10000;
|
||||
for (byte i = 0; i < 9; i++) {
|
||||
ItemStack item = inv[i];
|
||||
if (inv[i] == null) {
|
||||
continue;
|
||||
}
|
||||
if (item.getItem() instanceof ItemFood && !item.getItem().getUnlocalizedName(item).equals("item.spiderEye")) {
|
||||
int healing = ((ItemFood) (item.getItem())).getHealAmount(item);
|
||||
if (healing <= foodNeeded) {//whatever heals the least. wait that doesn't make sense. idk
|
||||
slotForFood = i;
|
||||
}
|
||||
if (anything && healing > foodNeeded && healing < worst) {//whatever wastes the least
|
||||
slotForFood = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (slotForFood != -1) {
|
||||
MovementManager.clearMovement();
|
||||
p.inventory.currentItem = slotForFood;
|
||||
MovementManager.sneak = true;
|
||||
if (whatAreYouLookingAt() == null) {
|
||||
MovementManager.isRightClick = true;
|
||||
} else {
|
||||
if (p.isSneaking()) {//if we are looking at a block, then sneak because you dont know what right click will do
|
||||
MovementManager.isRightClick = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected void onCancel() {
|
||||
}
|
||||
@Override
|
||||
protected void onStart() {
|
||||
}
|
||||
@Override
|
||||
protected boolean onEnabled(boolean enabled) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,569 +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.inventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import baritone.inventory.InventoryManager;
|
||||
import baritone.ui.LookManager;
|
||||
import baritone.util.Memory;
|
||||
import baritone.Baritone;
|
||||
import baritone.movement.MovementManager;
|
||||
import baritone.mining.MickeyMine;
|
||||
import baritone.pathfinding.goals.GoalBlock;
|
||||
import baritone.pathfinding.goals.GoalComposite;
|
||||
import baritone.util.Manager;
|
||||
import baritone.util.ManagerTick;
|
||||
import baritone.util.Out;
|
||||
import static baritone.inventory.CraftingTask.placeHeldBlockNearby;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiFurnace;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public class SmeltingTask extends ManagerTick {
|
||||
static HashMap<BlockPos, SmeltingTask> furnacesInUse = new HashMap();//smelting tasks that have been put in a furnace are here
|
||||
static ArrayList<SmeltingTask> inProgress = new ArrayList();//all smelting tasks will be in here
|
||||
public static boolean coalOnly = false;
|
||||
public static boolean avoidBreaking(BlockPos pos) {
|
||||
return furnacesInUse.containsKey(pos);
|
||||
}
|
||||
public static Manager createInstance(Class c) {
|
||||
return new SmeltingTask();
|
||||
}
|
||||
private SmeltingTask() {
|
||||
toPutInTheFurnace = null;
|
||||
desired = null;
|
||||
burnTicks = 0;
|
||||
}
|
||||
@Override
|
||||
protected boolean onTick0() {
|
||||
for (SmeltingTask task : new ArrayList<SmeltingTask>(inProgress)) {//make a copy because of concurrent modification bs
|
||||
if (task.plan != null) {
|
||||
task.exec();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (SmeltingTask task : new ArrayList<SmeltingTask>(inProgress)) {//make a copy because of concurrent modification bs
|
||||
if (task.exec()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static int tasksFor(Item result) {
|
||||
int sum = 0;
|
||||
for (SmeltingTask task : inProgress) {
|
||||
if (result.equals(task.desired.getItem())) {
|
||||
sum += task.desired.stackSize;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
public static void clearInProgress() {
|
||||
for (int i = 0; i < inProgress.size(); i++) {
|
||||
if (inProgress.get(i).isItDone) {
|
||||
inProgress.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static BlockPos getUnusedFurnace() {
|
||||
BlockPos best = null;
|
||||
double bestDist = Double.MAX_VALUE;
|
||||
for (BlockPos pos : Memory.closest(100, "furnace", "lit_furnace")) {
|
||||
if (furnacesInUse.get(pos) != null) {
|
||||
continue;
|
||||
}
|
||||
double dist = dist(pos);
|
||||
if (best == null || dist < bestDist) {
|
||||
bestDist = dist;
|
||||
best = pos;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
public static double dist(BlockPos pos) {
|
||||
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
||||
double diffX = thePlayer.posX - pos.getX();
|
||||
double diffY = thePlayer.posY - pos.getY();
|
||||
double diffZ = thePlayer.posZ - pos.getZ();
|
||||
return Math.sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ);
|
||||
}
|
||||
private final ItemStack toPutInTheFurnace;
|
||||
private final ItemStack desired;
|
||||
private BlockPos furnace = null;
|
||||
private boolean didIPutItInAlreadyPhrasing = false;
|
||||
private boolean isItDone = false;
|
||||
public final int burnTicks;
|
||||
public SmeltingTask(ItemStack desired) {
|
||||
toPutInTheFurnace = recipe(desired);
|
||||
if (toPutInTheFurnace == null) {
|
||||
String m = "Babe I can't smelt anyting to make " + desired;
|
||||
Out.gui(m, Out.Mode.Minimal);
|
||||
throw new IllegalArgumentException(m);
|
||||
}
|
||||
burnTicks = toPutInTheFurnace.stackSize * 200;
|
||||
this.desired = desired;
|
||||
}
|
||||
public void begin() {
|
||||
if (inProgress.contains(this)) {
|
||||
return;
|
||||
}
|
||||
inProgress.add(this);
|
||||
//todo: merge different smelting tasks for the same item
|
||||
}
|
||||
int numTicks = -20;//wait a couple extra ticks, for no reason (I guess server lag maybe)
|
||||
int guiWaitTicks = 0;
|
||||
int shiftWaitTicks = 0;
|
||||
private boolean exec() {
|
||||
Out.log(didIPutItInAlreadyPhrasing + " " + isItDone + " " + numTicks + " " + burnTicks + " " + furnace + " " + Minecraft.getMinecraft().currentScreen == null);
|
||||
if (!didIPutItInAlreadyPhrasing && Minecraft.getMinecraft().currentScreen == null) {
|
||||
BlockPos furnaceLocation = getUnusedFurnace();
|
||||
if (furnaceLocation != null) {
|
||||
if (LookManager.couldIReach(furnaceLocation)) {
|
||||
LookManager.lookAtBlock(furnaceLocation, true);
|
||||
if (furnaceLocation.equals(Baritone.whatAreYouLookingAt())) {
|
||||
furnace = furnaceLocation;
|
||||
Baritone.currentPath = null;
|
||||
MovementManager.clearMovement();
|
||||
Minecraft.getMinecraft().rightClickMouse();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
double diffX = furnaceLocation.getX() + 0.5D - Minecraft.getMinecraft().player.posX;
|
||||
double diffY = furnaceLocation.getY() + 0.5D - Minecraft.getMinecraft().player.posY;
|
||||
double diffZ = furnaceLocation.getZ() + 0.5D - Minecraft.getMinecraft().player.posZ;
|
||||
double distXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
|
||||
if (distXZ < 50 && Math.abs(diffY) < 20) {
|
||||
Baritone.goal = new GoalComposite(new GoalBlock(furnaceLocation.up()), new GoalBlock(furnaceLocation.north()), new GoalBlock(furnaceLocation.south()), new GoalBlock(furnaceLocation.east()), new GoalBlock(furnaceLocation.west()), new GoalBlock(furnaceLocation.north().down()), new GoalBlock(furnaceLocation.south().down()), new GoalBlock(furnaceLocation.east().down()), new GoalBlock(furnaceLocation.west().down()));
|
||||
if (Baritone.currentPath == null && !Baritone.isPathFinding()) {
|
||||
Baritone.findPathInNewThread(false);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
Out.gui("too far away from closest furnace (" + distXZ + " blocks), crafting another", Out.Mode.Standard);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (putFurnaceOnHotBar()) {
|
||||
Out.log("Ready to place!");
|
||||
if (placeHeldBlockNearby()) {
|
||||
return true;
|
||||
}
|
||||
BlockPos player = Baritone.playerFeet;
|
||||
if (Baritone.isAir(player.down()) || Baritone.isAir(player.up(2))) {
|
||||
Out.gui("Placing down", Out.Mode.Debug);
|
||||
LookManager.lookAtBlock(Baritone.playerFeet.down(), true);
|
||||
MovementManager.jumping = true;
|
||||
if (Baritone.playerFeet.down().equals(Baritone.whatAreYouLookingAt()) || Baritone.playerFeet.down().down().equals(Baritone.whatAreYouLookingAt())) {
|
||||
Minecraft.getMinecraft().rightClickMouse();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} else if (hasFurnaceInInventory()) {
|
||||
InventoryManager.putOnHotBar(Item.getByNameOrId("furnace"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
boolean guiOpen = Minecraft.getMinecraft().currentScreen != null && Minecraft.getMinecraft().currentScreen instanceof GuiFurnace;
|
||||
boolean ret = false;
|
||||
if (guiOpen) {
|
||||
guiWaitTicks++;
|
||||
if (guiWaitTicks < 5) {
|
||||
guiOpen = false;
|
||||
}
|
||||
if (!didIPutItInAlreadyPhrasing) {
|
||||
if (furnace == null) {
|
||||
furnace = Baritone.whatAreYouLookingAt();
|
||||
}
|
||||
furnacesInUse.put(furnace, this);
|
||||
ret = true;
|
||||
}
|
||||
} else {
|
||||
guiWaitTicks = 0;
|
||||
}
|
||||
if (guiOpen) {
|
||||
GuiFurnace contain = (GuiFurnace) Minecraft.getMinecraft().currentScreen;
|
||||
if (!didIPutItInAlreadyPhrasing) {
|
||||
Boolean b = realPutItIn_PHRASING(contain);
|
||||
if (b != null && b) {
|
||||
didIPutItInAlreadyPhrasing = true;
|
||||
ret = true;//done
|
||||
}
|
||||
if (b == null) {
|
||||
ret = true;//in progress
|
||||
}
|
||||
if (b != null && !b) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
if (isItDone && furnace.equals(Baritone.whatAreYouLookingAt())) {//if we are done, and this is our furnace
|
||||
ret = true;
|
||||
Out.gui("taking it out", Out.Mode.Debug);
|
||||
if (isEmpty(contain, 2)) {//make sure
|
||||
if (shiftWaitTicks > 5) {
|
||||
Minecraft.getMinecraft().player.closeScreen();//close the screen
|
||||
inProgress.remove(this);//no longer an in progress smelting dask
|
||||
Out.gui("Smelting " + desired + " totally done m9", Out.Mode.Debug);
|
||||
return false;
|
||||
}
|
||||
shiftWaitTicks++;
|
||||
} else {
|
||||
shiftWaitTicks = 0;
|
||||
if (numTicks % 5 == 0) {
|
||||
contain.shiftClick(2);//take out the output
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (didIPutItInAlreadyPhrasing) {
|
||||
numTicks++;
|
||||
if (Memory.blockLoaded(furnace)) {
|
||||
Block curr = Minecraft.getMinecraft().world.getBlockState(furnace).getBlock();
|
||||
if (!Block.getBlockFromName("furnace").equals(curr) && !Block.getBlockFromName("lit_furnace").equals(curr)) {
|
||||
Out.gui("Furnace at " + furnace + " is now gone. RIP. Was trying to make " + desired + ". Is now " + curr, Out.Mode.Standard);
|
||||
inProgress.remove(this);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!isItDone && numTicks >= burnTicks) {
|
||||
isItDone = true;
|
||||
Out.gui("Hey we're done. Go to your furnace at " + furnace + " and pick up " + desired, Out.Mode.Debug);
|
||||
furnacesInUse.put(furnace, null);
|
||||
}
|
||||
if (isItDone) {
|
||||
MickeyMine.tempDisable = true;
|
||||
}
|
||||
if (isItDone && !guiOpen) {
|
||||
if (LookManager.couldIReach(furnace)) {
|
||||
Baritone.currentPath = null;
|
||||
MovementManager.clearMovement();
|
||||
LookManager.lookAtBlock(furnace, true);
|
||||
if (furnace.equals(Baritone.whatAreYouLookingAt())) {
|
||||
Minecraft.getMinecraft().rightClickMouse();
|
||||
}
|
||||
} else {
|
||||
Baritone.goal = new GoalComposite(new GoalBlock(furnace.up()), new GoalBlock(furnace.north()), new GoalBlock(furnace.south()), new GoalBlock(furnace.east()), new GoalBlock(furnace.west()), new GoalBlock(furnace.north().down()), new GoalBlock(furnace.south().down()), new GoalBlock(furnace.east().down()), new GoalBlock(furnace.west().down()));
|
||||
if (Baritone.currentPath == null && !Baritone.isThereAnythingInProgress) {
|
||||
Baritone.findPathInNewThread(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isItDone && (numTicks - 1) % (60 * 20) == 0) {
|
||||
Out.gui("DUDE. Go to your furnace at " + furnace + " and pick up " + desired + ". Do /cancelfurnace if you want these notifications to piss off.", Out.Mode.Minimal);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public static boolean hasFurnaceInInventory() {
|
||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||
ItemStack[] inv = p.inventory.mainInventory;
|
||||
for (ItemStack item : inv) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
if (Item.getByNameOrId("minecraft:furnace").equals(item.getItem())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean putFurnaceOnHotBar() {//shamelessly copied from MickeyMine.torch()
|
||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||
ItemStack[] inv = p.inventory.mainInventory;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack item = inv[i];
|
||||
if (inv[i] == null) {
|
||||
continue;
|
||||
}
|
||||
if (Item.getByNameOrId("furnace").equals(item.getItem())) {
|
||||
p.inventory.currentItem = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean isInFurnace() {
|
||||
return didIPutItInAlreadyPhrasing;
|
||||
}
|
||||
public boolean lookingForFurnace() {
|
||||
return furnace == null;
|
||||
}
|
||||
private ArrayList<int[]> plan;
|
||||
int tickNumber = 0;
|
||||
static int ticksBetweenClicks = 4;
|
||||
public boolean tickPlan() {
|
||||
GuiContainer contain = (GuiContainer) Minecraft.getMinecraft().currentScreen;
|
||||
if (tickNumber % ticksBetweenClicks == 0) {
|
||||
int index = tickNumber / ticksBetweenClicks;
|
||||
if (index >= plan.size()) {
|
||||
if (index >= plan.size() + 2) {
|
||||
Out.gui("Plan over", Out.Mode.Debug);
|
||||
plan = null;
|
||||
tickNumber = -40;
|
||||
Minecraft.getMinecraft().player.closeScreen();
|
||||
return true;
|
||||
}
|
||||
tickNumber++;
|
||||
return false;
|
||||
}
|
||||
if (index >= 0) {
|
||||
int[] click = plan.get(index);
|
||||
Out.gui(index + " " + click[0] + " " + click[1] + " " + click[2] + " " + desired, Out.Mode.Debug);
|
||||
contain.sketchyMouseClick(click[0], click[1], click[2]);
|
||||
Out.log("Ticking plan");
|
||||
}
|
||||
}
|
||||
tickNumber++;
|
||||
return false;
|
||||
}
|
||||
private Boolean realPutItIn_PHRASING(GuiFurnace contain) {//null: in progress. false: unable. true: done
|
||||
if (plan == null) {
|
||||
if (!generatePlan(contain)) {
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (tickPlan()) {
|
||||
return true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private boolean generatePlan(GuiFurnace contain) {
|
||||
int desiredAmount = toPutInTheFurnace.stackSize;
|
||||
if (currentSize1(contain, 0, toPutInTheFurnace.getItem()) == -1) {
|
||||
Out.gui("Furnace already in use", Out.Mode.Debug);
|
||||
return false;
|
||||
}
|
||||
ArrayList<Item> burnableItems = new ArrayList<Item>();
|
||||
ArrayList<Integer> burnTimes = new ArrayList<Integer>();
|
||||
ArrayList<Integer> amountWeHave = new ArrayList<Integer>();
|
||||
ArrayList<Integer> amtNeeded = new ArrayList<Integer>();
|
||||
for (int i = 3; i < contain.inventorySlots.inventorySlots.size(); i++) {
|
||||
Slot slot = contain.inventorySlots.inventorySlots.get(i);
|
||||
if (!slot.getHasStack()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack in = slot.getStack();
|
||||
if (in == null) {
|
||||
continue;
|
||||
}
|
||||
Item item = in.getItem();
|
||||
int ind = burnableItems.indexOf(item);
|
||||
if (ind == -1) {
|
||||
int time = TileEntityFurnace.getItemBurnTime(in);
|
||||
if (time <= 0) {
|
||||
Out.gui(in + " isn't fuel, lol", Out.Mode.Standard);
|
||||
continue;
|
||||
}
|
||||
burnableItems.add(in.getItem());
|
||||
amountWeHave.add(in.stackSize);
|
||||
burnTimes.add(time);
|
||||
int numRequired = (int) Math.ceil(((double) burnTicks) / (time));
|
||||
amtNeeded.add(numRequired);
|
||||
} else {
|
||||
amountWeHave.set(ind, amountWeHave.get(ind) + in.stackSize);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < burnableItems.size(); i++) {
|
||||
if (amountWeHave.get(i) < amtNeeded.get(i)) {
|
||||
Out.gui("Not using fuel " + burnableItems.get(i) + " because not enough (have " + amountWeHave.get(i) + ", need " + amtNeeded.get(i) + ")", Out.Mode.Standard);
|
||||
burnableItems.remove(i);
|
||||
amountWeHave.remove(i);
|
||||
amtNeeded.remove(i);
|
||||
burnTimes.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if (burnableItems.isEmpty()) {
|
||||
Out.gui("lol no fuel", Out.Mode.Standard);
|
||||
return false;
|
||||
}
|
||||
Out.log(burnableItems);
|
||||
Out.log(amountWeHave);
|
||||
Out.log(amtNeeded);
|
||||
Out.log(burnTimes);
|
||||
Item bestFuel = null;
|
||||
int fuelAmt = Integer.MAX_VALUE;
|
||||
int bestExtra = Integer.MAX_VALUE;
|
||||
for (int i = 0; i < burnableItems.size(); i++) {
|
||||
int amt = amtNeeded.get(i);
|
||||
int extra = burnTimes.get(i) * amtNeeded.get(i) - burnTicks;
|
||||
boolean better = extra < bestExtra || (extra == bestExtra && amt < fuelAmt);
|
||||
boolean thisisCoal = Item.getByNameOrId("coal").equals(burnableItems.get(i));
|
||||
boolean bestIsCoal = Item.getByNameOrId("coal").equals(bestFuel);
|
||||
if ((better && !coalOnly) || (coalOnly && ((thisisCoal && !bestIsCoal) || (thisisCoal && bestIsCoal && better) || (!thisisCoal && !bestIsCoal && better)))) {
|
||||
fuelAmt = amt;
|
||||
bestExtra = extra;
|
||||
bestFuel = burnableItems.get(i);
|
||||
}
|
||||
}
|
||||
Out.gui("Using " + fuelAmt + " items of " + bestFuel + ", which wastes " + bestExtra + " ticks of fuel.", Out.Mode.Debug);
|
||||
int currFuelSize = 0;
|
||||
if (currentSize1(contain, 1, bestFuel) == -1) {
|
||||
Out.gui("Furnace already in use", Out.Mode.Debug);
|
||||
return false;
|
||||
}
|
||||
if (currentSize1(contain, 0, toPutInTheFurnace.getItem()) == -1) {
|
||||
Out.gui("Furnace already in use", Out.Mode.Debug);
|
||||
return false;
|
||||
}
|
||||
plan = new ArrayList();
|
||||
tickNumber = -10;
|
||||
int currSmeltSize = 0;
|
||||
for (int i = 3; i < contain.inventorySlots.inventorySlots.size(); i++) {
|
||||
Slot slot = contain.inventorySlots.inventorySlots.get(i);
|
||||
if (!slot.getHasStack()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack in = slot.getStack();
|
||||
if (in == null) {
|
||||
continue;
|
||||
}
|
||||
if (in.getItem().equals(toPutInTheFurnace.getItem())) {
|
||||
int amountHere = in.stackSize;
|
||||
int amountNeeded = desiredAmount - currSmeltSize;
|
||||
leftClick(i);
|
||||
if (amountNeeded >= amountHere) {
|
||||
leftClick(0);
|
||||
currSmeltSize += amountHere;
|
||||
leftClick(i);
|
||||
} else {
|
||||
for (int j = 0; j < amountNeeded; j++) {
|
||||
rightClick(0);
|
||||
}
|
||||
leftClick(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 3; i < contain.inventorySlots.inventorySlots.size(); i++) {
|
||||
Slot slot = contain.inventorySlots.inventorySlots.get(i);
|
||||
if (!slot.getHasStack()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack in = slot.getStack();
|
||||
if (in == null) {
|
||||
continue;
|
||||
}
|
||||
if (in.getItem().equals(bestFuel)) {
|
||||
int currentSize = currFuelSize;
|
||||
int amountHere = in.stackSize;
|
||||
int amountNeeded = fuelAmt - currentSize;
|
||||
leftClick(i);
|
||||
if (amountNeeded >= amountHere) {
|
||||
leftClick(1);
|
||||
currFuelSize += amountHere;
|
||||
leftClick(i);
|
||||
} else {
|
||||
for (int j = 0; j < amountNeeded; j++) {
|
||||
rightClick(1);
|
||||
}
|
||||
leftClick(i);
|
||||
Out.gui("done with fuel", Out.Mode.Debug);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void leftClick(int slot) {
|
||||
if (!plan.isEmpty()) {
|
||||
int[] last = plan.get(plan.size() - 1);
|
||||
if (last[0] == slot && last[1] == 0 && last[2] == 0) {
|
||||
plan.remove(plan.size() - 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
plan.add(new int[]{slot, 0, 0});
|
||||
}
|
||||
public void rightClick(int slot) {
|
||||
plan.add(new int[]{slot, 1, 0});
|
||||
}
|
||||
public void shiftClick(int slot) {
|
||||
plan.add(new int[]{slot, 0, 1});
|
||||
}
|
||||
private static boolean isEmpty(GuiFurnace contain, int id) {
|
||||
Slot slot = contain.inventorySlots.inventorySlots.get(id);
|
||||
if (!slot.getHasStack()) {
|
||||
return true;
|
||||
}
|
||||
return slot.getStack() == null;
|
||||
}
|
||||
private static int currentSize1(GuiFurnace contain, int id, Item item) {
|
||||
Slot slot = contain.inventorySlots.inventorySlots.get(id);
|
||||
if (!slot.getHasStack()) {
|
||||
return 0;
|
||||
}
|
||||
ItemStack in = slot.getStack();
|
||||
if (in == null) {
|
||||
return 0;
|
||||
}
|
||||
if (!in.getItem().equals(item)) {
|
||||
return -1;
|
||||
}
|
||||
return in.stackSize;
|
||||
}
|
||||
private static ItemStack recipe(ItemStack desired) {
|
||||
for (Entry<ItemStack, ItemStack> recipe : getRecipes().entrySet()) {
|
||||
ItemStack input = recipe.getKey();
|
||||
ItemStack output = recipe.getValue();
|
||||
if (output.getItem().equals(desired.getItem())) {
|
||||
int desiredQuantity = desired.stackSize;
|
||||
int outputQuantity = output.stackSize;
|
||||
int totalQuantity = (int) Math.ceil(((double) desiredQuantity) / (outputQuantity));
|
||||
int inputQuantity = input.stackSize * totalQuantity;
|
||||
Out.log("Recipe from " + input + " to " + output + " " + desiredQuantity + " " + outputQuantity + " " + totalQuantity + " " + inputQuantity);
|
||||
if (inputQuantity > 64) {
|
||||
throw new IllegalStateException("lol");
|
||||
}
|
||||
return new ItemStack(input.getItem(), inputQuantity, input.getMetadata());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected void onCancel() {
|
||||
inProgress.clear();
|
||||
furnacesInUse.clear();
|
||||
}
|
||||
@Override
|
||||
protected void onStart() {
|
||||
}
|
||||
@Override
|
||||
protected boolean onEnabled(boolean enabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class wrapper {//so that people don't try to directly reference recipess
|
||||
private static Map<ItemStack, ItemStack> recipes = null;
|
||||
public static Map<ItemStack, ItemStack> getRecipes() {
|
||||
if (recipes == null) {
|
||||
recipes = FurnaceRecipes.instance().getSmeltingList();
|
||||
}
|
||||
return recipes;
|
||||
}
|
||||
}
|
||||
public static Map<ItemStack, ItemStack> getRecipes() {
|
||||
return wrapper.getRecipes();
|
||||
}
|
||||
}
|
@ -283,7 +283,7 @@ public class MickeyMine extends ManagerTick {
|
||||
}
|
||||
ArrayList<BlockPos> shouldBeRemoved = new ArrayList<BlockPos>();
|
||||
for (BlockPos isMined : needsToBeMined) {
|
||||
Block block = net.minecraft.client.Minecraft.getMinecraft().world.getBlockState(isMined).getBlock();
|
||||
Block block = net.minecraft.client.Baritone.get(isMined).getBlock();
|
||||
if (isGoalBlock(isMined) || block.equals(Block.getBlockById(0)) || block.equals(Block.getBlockFromName("minecraft:torch")) || block.equals(Blocks.BEDROCK)) {
|
||||
hasBeenMined.add(isMined);
|
||||
shouldBeRemoved.add(isMined);
|
||||
@ -300,7 +300,7 @@ public class MickeyMine extends ManagerTick {
|
||||
boolean wasEmpty = priorityNeedsToBeMined.isEmpty();
|
||||
ArrayList<BlockPos> shouldBeRemoved = new ArrayList<BlockPos>();
|
||||
for (BlockPos isMined : priorityNeedsToBeMined) {
|
||||
Block block = net.minecraft.client.Minecraft.getMinecraft().world.getBlockState(isMined).getBlock();
|
||||
Block block = net.minecraft.client.Baritone.get(isMined).getBlock();
|
||||
if (block.equals(Block.getBlockById(0)) || block.equals(Block.getBlockFromName("minecraft:torch")) || block.equals(Blocks.BEDROCK)) {
|
||||
hasBeenMined.add(isMined);
|
||||
shouldBeRemoved.add(isMined);
|
||||
@ -353,11 +353,11 @@ public class MickeyMine extends ManagerTick {
|
||||
public static boolean addPriorityBlock(BlockPos blockPos) {
|
||||
if (!priorityNeedsToBeMined.contains(blockPos) && isGoalBlock(blockPos)) {
|
||||
if (Action.avoidBreaking(blockPos)) {
|
||||
Out.gui("Can't break " + Minecraft.getMinecraft().world.getBlockState(blockPos).getBlock() + " at " + blockPos + " because it's near lava", Out.Mode.Debug);
|
||||
Out.gui("Can't break " + Baritone.get(blockPos).getBlock() + " at " + blockPos + " because it's near lava", Out.Mode.Debug);
|
||||
return false;
|
||||
}
|
||||
priorityNeedsToBeMined.add(blockPos);
|
||||
if (Block.getBlockFromName("minecraft:diamond_ore").equals(Minecraft.getMinecraft().world.getBlockState(blockPos).getBlock())) {
|
||||
if (Block.getBlockFromName("minecraft:diamond_ore").equals(Baritone.get(blockPos).getBlock())) {
|
||||
chunkHasDiamonds.add(tupleFromBlockPos(blockPos));
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
@ -376,7 +376,7 @@ public class MickeyMine extends ManagerTick {
|
||||
}
|
||||
|
||||
public static boolean isGoalBlock(BlockPos blockPos) {
|
||||
return isGoalBlock(Minecraft.getMinecraft().world.getBlockState(blockPos).getBlock());
|
||||
return isGoalBlock(Baritone.get(blockPos).getBlock());
|
||||
}
|
||||
|
||||
public static boolean isGoalBlock(Block block) {
|
||||
|
@ -38,7 +38,7 @@ public class MovementManager {
|
||||
return moveTowardsBlock(p, true);
|
||||
}
|
||||
public static boolean moveTowardsBlock(BlockPos p, boolean rotate) {
|
||||
Block b = Minecraft.getMinecraft().world.getBlockState(p).getBlock();
|
||||
Block b = Baritone.get(p).getBlock();
|
||||
double xDiff = (b.getBlockBoundsMinX() + b.getBlockBoundsMaxX()) / 2;
|
||||
double yolo = (b.getBlockBoundsMinY() + b.getBlockBoundsMaxY()) / 2;
|
||||
double zDiff = (b.getBlockBoundsMinZ() + b.getBlockBoundsMaxZ()) / 2;
|
||||
|
@ -80,7 +80,7 @@ public class Path {
|
||||
public void showPathInStone() {
|
||||
IBlockState[] originalStates = new IBlockState[path.size()];
|
||||
for (int i = 0; i < path.size(); i++) {
|
||||
originalStates[i] = Minecraft.getMinecraft().world.getBlockState(path.get(i));
|
||||
originalStates[i] = Baritone.get(path.get(i));
|
||||
Minecraft.getMinecraft().world.setBlockState(path.get(i), Block.getBlockById(1).getDefaultState());
|
||||
try {
|
||||
Thread.sleep(250);
|
||||
@ -163,7 +163,7 @@ public class Path {
|
||||
}
|
||||
if (!whereShouldIBe.equals(whereAmI)) {
|
||||
Out.log("Should be at " + whereShouldIBe + " actually am at " + whereAmI);
|
||||
if (!Blocks.air.equals(Minecraft.getMinecraft().world.getBlockState(thePlayer.getPosition0().down()))) {//do not skip if standing on air, because our position isn't stable to skip
|
||||
if (!Blocks.air.equals(Baritone.get(thePlayer.getPosition0().down()))) {//do not skip if standing on air, because our position isn't stable to skip
|
||||
for (int i = 0; i < pathPosition - 2 && i < path.size(); i++) {//this happens for example when you lag out and get teleported back a couple blocks
|
||||
if (whereAmI.equals(path.get(i))) {
|
||||
Out.gui("Skipping back " + (pathPosition - i) + " steps, to " + i, Out.Mode.Debug);
|
||||
@ -203,8 +203,8 @@ public class Path {
|
||||
if (curr.amIGood() && next.amIGood()) {//nothing in the way
|
||||
BlockPos cornerToCut1 = new BlockPos(next.to.getX() - next.from.getX() + curr.from.getX(), next.to.getY(), next.to.getZ() - next.from.getZ() + curr.from.getZ());
|
||||
BlockPos cornerToCut2 = cornerToCut1.up();
|
||||
//Block corner1 = Minecraft.getMinecraft().world.getBlockState(cornerToCut1).getBlock();
|
||||
//Block corner2 = Minecraft.getMinecraft().world.getBlockState(cornerToCut2).getBlock();
|
||||
//Block corner1 = Baritone.get(cornerToCut1).getBlock();
|
||||
//Block corner2 = Baritone.get(cornerToCut2).getBlock();
|
||||
//Out.gui("Cutting conner " + cornerToCut1 + " " + corner1, Out.Mode.Debug);
|
||||
if (!Action.avoidWalkingInto(cornerToCut1) && !Action.avoidWalkingInto(cornerToCut2)) {
|
||||
double x = (next.from.getX() + next.to.getX() + 1.0D) * 0.5D;
|
||||
|
@ -87,7 +87,7 @@ public abstract class Action {
|
||||
|
||||
public double calculateCost0(ToolSet ts) {
|
||||
if (!(this instanceof ActionPillar) && !(this instanceof ActionBridge) && !(this instanceof ActionFall)) {
|
||||
Block fromDown = Minecraft.getMinecraft().world.getBlockState(from.down()).getBlock();
|
||||
Block fromDown = Baritone.get(from.down()).getBlock();
|
||||
if (fromDown instanceof BlockLadder || fromDown instanceof BlockVine) {
|
||||
return COST_INF;
|
||||
}
|
||||
@ -112,7 +112,7 @@ public abstract class Action {
|
||||
}
|
||||
|
||||
public static boolean isWater(BlockPos bp) {
|
||||
return isWater(Minecraft.getMinecraft().world.getBlockState(bp).getBlock());
|
||||
return isWater(Baritone.get(bp).getBlock());
|
||||
}
|
||||
|
||||
public static boolean isLiquid(Block b) {
|
||||
@ -135,12 +135,12 @@ public abstract class Action {
|
||||
}
|
||||
|
||||
public static boolean isLiquid(BlockPos p) {
|
||||
return isLiquid(Minecraft.getMinecraft().world.getBlockState(p).getBlock());
|
||||
return isLiquid(Baritone.get(p).getBlock());
|
||||
}
|
||||
|
||||
public static boolean avoidBreaking(BlockPos pos) {
|
||||
Block b = Minecraft.getMinecraft().world.getBlockState(pos).getBlock();
|
||||
Block below = Minecraft.getMinecraft().world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
|
||||
Block b = Baritone.get(pos).getBlock();
|
||||
Block below = Baritone.get(new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())).getBlock();
|
||||
return Block.getBlockFromName("minecraft:ice").equals(b)//ice becomes water, and water can mess up the path
|
||||
|| isLiquid(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))//don't break anything touching liquid on any side
|
||||
|| isLiquid(new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ()))
|
||||
@ -157,7 +157,7 @@ public abstract class Action {
|
||||
* @return
|
||||
*/
|
||||
public static boolean canWalkThrough(BlockPos pos) {
|
||||
IBlockState state = Minecraft.getMinecraft().world.getBlockState(pos);
|
||||
IBlockState state = Baritone.get(pos);
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof BlockLilyPad || block instanceof BlockFire) {//you can't actually walk through a lilypad from the side, and you shouldn't walk through fire
|
||||
return false;
|
||||
@ -172,7 +172,7 @@ public abstract class Action {
|
||||
}
|
||||
|
||||
public static boolean avoidWalkingInto(BlockPos pos) {
|
||||
Block block = Minecraft.getMinecraft().world.getBlockState(pos).getBlock();
|
||||
Block block = Baritone.get(pos).getBlock();
|
||||
if (isLava(block)) {
|
||||
return true;
|
||||
}
|
||||
@ -191,7 +191,7 @@ public abstract class Action {
|
||||
* @return
|
||||
*/
|
||||
public static boolean canWalkOn(BlockPos pos) {
|
||||
IBlockState state = Minecraft.getMinecraft().world.getBlockState(pos);
|
||||
IBlockState state = Baritone.get(pos);
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof BlockLadder || block instanceof BlockVine) {
|
||||
return true;
|
||||
|
@ -60,13 +60,13 @@ public class ActionBridge extends ActionPlaceOrBreak {
|
||||
return WC + getTotalHardnessOfBlocksToBreak(ts);
|
||||
} else {//this is a bridge, so we need to place a block
|
||||
//return 1000000;
|
||||
Block f = Minecraft.getMinecraft().world.getBlockState(from.down()).getBlock();
|
||||
Block f = Baritone.get(from.down()).getBlock();
|
||||
if (f instanceof BlockLadder || f instanceof BlockVine) {
|
||||
return COST_INF;
|
||||
}
|
||||
if (blocksToPlace[0].equals(Block.getBlockById(0)) || (!isWater(blocksToPlace[0]) && blocksToPlace[0].isReplaceable(Minecraft.getMinecraft().world, positionsToPlace[0]))) {
|
||||
for (BlockPos against1 : against) {
|
||||
if (Minecraft.getMinecraft().world.getBlockState(against1).getBlock().isBlockNormalCube()) {
|
||||
if (Baritone.get(against1).getBlock().isBlockNormalCube()) {
|
||||
return WC + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(ts);
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class ActionBridge extends ActionPlaceOrBreak {
|
||||
return WC + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(ts);
|
||||
}
|
||||
return COST_INF;
|
||||
//Out.log("Can't walk on " + Minecraft.getMinecraft().world.getBlockState(positionsToPlace[0]).getBlock());
|
||||
//Out.log("Can't walk on " + Baritone.get(positionsToPlace[0]).getBlock());
|
||||
}
|
||||
}
|
||||
boolean wasTheBridgeBlockAlwaysThere = true;//did we have to place a bridge block or was it always there
|
||||
@ -93,10 +93,10 @@ public class ActionBridge extends ActionPlaceOrBreak {
|
||||
if (oneInTen == null) {
|
||||
oneInTen = new Random().nextInt(10) == 0;
|
||||
}
|
||||
Block fd = Minecraft.getMinecraft().world.getBlockState(from.down()).getBlock();
|
||||
Block fd = Baritone.get(from.down()).getBlock();
|
||||
boolean ladder = fd instanceof BlockLadder || fd instanceof BlockVine;
|
||||
boolean isTheBridgeBlockThere = canWalkOn(positionsToPlace[0]) || ladder;
|
||||
//Out.log("is block there: " + isTheBridgeBlockThere + " block " + Minecraft.getMinecraft().world.getBlockState(positionsToPlace[0]).getBlock());
|
||||
//Out.log("is block there: " + isTheBridgeBlockThere + " block " + Baritone.get(positionsToPlace[0]).getBlock());
|
||||
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
||||
BlockPos whereAmI = new BlockPos(thePlayer.posX, thePlayer.posY, thePlayer.posZ);
|
||||
if (whereAmI.getY() != to.getY() && !ladder) {
|
||||
@ -128,7 +128,7 @@ public class ActionBridge extends ActionPlaceOrBreak {
|
||||
} else {
|
||||
wasTheBridgeBlockAlwaysThere = false;
|
||||
for (BlockPos against1 : against) {
|
||||
if (Minecraft.getMinecraft().world.getBlockState(against1).getBlock().isBlockNormalCube()) {
|
||||
if (Baritone.get(against1).getBlock().isBlockNormalCube()) {
|
||||
if (!switchtothrowaway(true)) {//get ready to place a throwaway block
|
||||
return false;
|
||||
}
|
||||
|
@ -53,13 +53,13 @@ public class ActionClimb extends ActionPlaceOrBreak {
|
||||
return COST_INF;
|
||||
}
|
||||
for (BlockPos against1 : against) {
|
||||
if (Minecraft.getMinecraft().world.getBlockState(against1).getBlock().isBlockNormalCube()) {
|
||||
if (Baritone.get(against1).getBlock().isBlockNormalCube()) {
|
||||
return JUMP_ONE_BLOCK_COST + WALK_ONE_BLOCK_COST + PLACE_ONE_BLOCK_COST + getTotalHardnessOfBlocksToBreak(ts);
|
||||
}
|
||||
}
|
||||
return COST_INF;
|
||||
}
|
||||
if (Minecraft.getMinecraft().world.getBlockState(from.up(3)).getBlock() instanceof BlockFalling) {//it would fall on us and possibly suffocate us
|
||||
if (Baritone.get(from.up(3)).getBlock() instanceof BlockFalling) {//it would fall on us and possibly suffocate us
|
||||
return COST_INF;
|
||||
}
|
||||
return WALK_ONE_BLOCK_COST / 2 + Math.max(JUMP_ONE_BLOCK_COST, WALK_ONE_BLOCK_COST / 2) + getTotalHardnessOfBlocksToBreak(ts);//we walk half the block to get to the edge, then we walk the other half while simultaneously jumping (math.max because of how it's in parallel)
|
||||
@ -70,7 +70,7 @@ public class ActionClimb extends ActionPlaceOrBreak {
|
||||
EntityPlayerSP thePlayer = Minecraft.getMinecraft().player;
|
||||
if (!canWalkOn(positionsToPlace[0])) {
|
||||
for (int i = 0; i < against.length; i++) {
|
||||
if (Minecraft.getMinecraft().world.getBlockState(against[i]).getBlock().isBlockNormalCube()) {
|
||||
if (Baritone.get(against[i]).getBlock().isBlockNormalCube()) {
|
||||
if (!switchtothrowaway(true)) {//get ready to place a throwaway block
|
||||
return false;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class ActionDescend extends ActionPlaceOrBreak {
|
||||
if (!canWalkOn(positionsToPlace[0])) {
|
||||
return COST_INF;
|
||||
}
|
||||
Block tmp1 = Minecraft.getMinecraft().world.getBlockState(to).getBlock();
|
||||
Block tmp1 = Baritone.get(to).getBlock();
|
||||
if (tmp1 instanceof BlockLadder || tmp1 instanceof BlockVine) {
|
||||
return COST_INF;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class ActionFall extends ActionPlaceOrBreak {
|
||||
if (!Baritone.allowVerticalMotion || !canWalkOn(to.down())) {
|
||||
return COST_INF;
|
||||
}
|
||||
Block td = Minecraft.getMinecraft().world.getBlockState(to).getBlock();
|
||||
Block td = Baritone.get(to).getBlock();
|
||||
boolean ladder = td instanceof BlockLadder || td instanceof BlockVine;
|
||||
if (ladder) {
|
||||
return LADDER_DOWN_ONE_COST;
|
||||
|
@ -29,10 +29,10 @@ public class ActionPillar extends ActionPlaceOrBreak {
|
||||
}
|
||||
@Override
|
||||
protected double calculateCost(ToolSet ts) {
|
||||
Block fromDown = Minecraft.getMinecraft().world.getBlockState(from).getBlock();
|
||||
Block fromDown = Baritone.get(from).getBlock();
|
||||
boolean ladder = fromDown instanceof BlockLadder || fromDown instanceof BlockVine;
|
||||
if (!ladder) {
|
||||
Block d = Minecraft.getMinecraft().world.getBlockState(from.down()).getBlock();
|
||||
Block d = Baritone.get(from.down()).getBlock();
|
||||
if (d instanceof BlockLadder || d instanceof BlockVine) {
|
||||
return COST_INF;
|
||||
}
|
||||
@ -47,10 +47,10 @@ public class ActionPillar extends ActionPlaceOrBreak {
|
||||
}
|
||||
double hardness = getTotalHardnessOfBlocksToBreak(ts);
|
||||
if (hardness != 0) {
|
||||
Block tmp = Minecraft.getMinecraft().world.getBlockState(from.up(2)).getBlock();
|
||||
Block tmp = Baritone.get(from.up(2)).getBlock();
|
||||
if (tmp instanceof BlockLadder || tmp instanceof BlockVine) {
|
||||
hardness = 0;
|
||||
} else if (!canWalkOn(from.up(3)) || canWalkThrough(from.up(3)) || Minecraft.getMinecraft().world.getBlockState(from.up(3)).getBlock() instanceof BlockFalling) {//if the block above where we want to break is not a full block, don't do it
|
||||
} else if (!canWalkOn(from.up(3)) || canWalkThrough(from.up(3)) || Baritone.get(from.up(3)).getBlock() instanceof BlockFalling) {//if the block above where we want to break is not a full block, don't do it
|
||||
return COST_INF;
|
||||
}
|
||||
}
|
||||
@ -65,23 +65,23 @@ public class ActionPillar extends ActionPlaceOrBreak {
|
||||
}
|
||||
int numTicks = 0;
|
||||
public BlockPos getAgainst(BlockPos vine) {
|
||||
if (Minecraft.getMinecraft().world.getBlockState(vine.north()).getBlock().isBlockNormalCube()) {
|
||||
if (Baritone.get(vine.north()).getBlock().isBlockNormalCube()) {
|
||||
return vine.north();
|
||||
}
|
||||
if (Minecraft.getMinecraft().world.getBlockState(vine.south()).getBlock().isBlockNormalCube()) {
|
||||
if (Baritone.get(vine.south()).getBlock().isBlockNormalCube()) {
|
||||
return vine.south();
|
||||
}
|
||||
if (Minecraft.getMinecraft().world.getBlockState(vine.east()).getBlock().isBlockNormalCube()) {
|
||||
if (Baritone.get(vine.east()).getBlock().isBlockNormalCube()) {
|
||||
return vine.east();
|
||||
}
|
||||
if (Minecraft.getMinecraft().world.getBlockState(vine.west()).getBlock().isBlockNormalCube()) {
|
||||
if (Baritone.get(vine.west()).getBlock().isBlockNormalCube()) {
|
||||
return vine.west();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected boolean tick0() {
|
||||
IBlockState fromDown = Minecraft.getMinecraft().world.getBlockState(from);
|
||||
IBlockState fromDown = Baritone.get(from);
|
||||
boolean ladder = fromDown.getBlock() instanceof BlockLadder || fromDown.getBlock() instanceof BlockVine;
|
||||
boolean vine = fromDown.getBlock() instanceof BlockVine;
|
||||
if (!ladder && !LookManager.lookAtBlock(positionsToPlace[0], true)) {
|
||||
@ -121,7 +121,7 @@ public class ActionPillar extends ActionPlaceOrBreak {
|
||||
}
|
||||
if (!blockIsThere) {
|
||||
Out.log("Block not there yet");
|
||||
Block fr = Minecraft.getMinecraft().world.getBlockState(from).getBlock();
|
||||
Block fr = Baritone.get(from).getBlock();
|
||||
if (!(Baritone.isAir(from) || fr.isReplaceable(Minecraft.getMinecraft().world, from))) {
|
||||
MovementManager.isLeftClick = true;
|
||||
blockIsThere = false;
|
||||
|
@ -5,22 +5,24 @@
|
||||
*/
|
||||
package baritone.pathfinding.actions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import baritone.Baritone;
|
||||
import baritone.inventory.SmeltingTask;
|
||||
import baritone.movement.MovementManager;
|
||||
import baritone.ui.LookManager;
|
||||
import baritone.util.Out;
|
||||
import baritone.util.ToolSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import baritone.ui.LookManager;
|
||||
import baritone.Baritone;
|
||||
import baritone.movement.MovementManager;
|
||||
import baritone.util.Out;
|
||||
import baritone.inventory.SmeltingTask;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFalling;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
@ -28,10 +30,12 @@ import net.minecraft.util.math.BlockPos;
|
||||
* @author leijurv
|
||||
*/
|
||||
public abstract class ActionPlaceOrBreak extends Action {
|
||||
|
||||
public final BlockPos[] positionsToBreak;//the positions that need to be broken before this action can ensue
|
||||
public final BlockPos[] positionsToPlace;//the positions where we need to place a block before this aciton can ensue
|
||||
public final Block[] blocksToBreak;//the blocks at those positions
|
||||
public final Block[] blocksToPlace;
|
||||
|
||||
public ActionPlaceOrBreak(BlockPos start, BlockPos end, BlockPos[] toBreak, BlockPos[] toPlace) {
|
||||
super(start, end);
|
||||
this.positionsToBreak = toBreak;
|
||||
@ -39,16 +43,18 @@ public abstract class ActionPlaceOrBreak extends Action {
|
||||
blocksToBreak = new Block[positionsToBreak.length];
|
||||
blocksToPlace = new Block[positionsToPlace.length];
|
||||
for (int i = 0; i < blocksToBreak.length; i++) {
|
||||
blocksToBreak[i] = Minecraft.getMinecraft().world.getBlockState(positionsToBreak[i]).getBlock();
|
||||
blocksToBreak[i] = Baritone.get(positionsToBreak[i]).getBlock();
|
||||
}
|
||||
for (int i = 0; i < blocksToPlace.length; i++) {
|
||||
blocksToPlace[i] = Minecraft.getMinecraft().world.getBlockState(positionsToPlace[i]).getBlock();
|
||||
blocksToPlace[i] = Baritone.get(positionsToPlace[i]).getBlock();
|
||||
}
|
||||
}
|
||||
|
||||
public double getTotalHardnessOfBlocksToBreak() {//of all the blocks we need to break before starting this action, what's the sum of how hard they are (phrasing)
|
||||
ToolSet ts = new ToolSet();
|
||||
return this.getTotalHardnessOfBlocksToBreak(ts);
|
||||
}
|
||||
|
||||
public double getTotalHardnessOfBlocksToBreak(ToolSet ts) {
|
||||
double sum = 0;
|
||||
HashSet<BlockPos> toBreak = new HashSet();
|
||||
@ -64,7 +70,7 @@ public abstract class ActionPlaceOrBreak extends Action {
|
||||
}
|
||||
}
|
||||
for (BlockPos pos : toBreak) {
|
||||
sum += getHardness(ts, Minecraft.getMinecraft().world.getBlockState(pos).getBlock(), pos);
|
||||
sum += getHardness(ts, Baritone.get(pos), pos);
|
||||
if (sum >= COST_INF) {
|
||||
return COST_INF;
|
||||
}
|
||||
@ -78,10 +84,12 @@ public abstract class ActionPlaceOrBreak extends Action {
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
public static boolean canFall(BlockPos pos) {
|
||||
return Minecraft.getMinecraft().world.getBlockState(pos).getBlock() instanceof BlockFalling;
|
||||
return Baritone.get(pos).getBlock() instanceof BlockFalling;
|
||||
}
|
||||
public static double getHardness(ToolSet ts, Block block, BlockPos position) {
|
||||
|
||||
public static double getHardness(ToolSet ts, IBlockState block, BlockPos position) {
|
||||
if (!block.equals(Block.getBlockById(0)) && !canWalkThrough(position)) {
|
||||
if (avoidBreaking(position)) {
|
||||
return COST_INF;
|
||||
@ -97,10 +105,12 @@ public abstract class ActionPlaceOrBreak extends Action {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getClass() + " place " + Arrays.asList(blocksToPlace) + " break " + Arrays.asList(blocksToBreak) + " cost " + cost(null) + " break cost " + getTotalHardnessOfBlocksToBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tick() {
|
||||
//breaking first
|
||||
@ -124,7 +134,7 @@ public abstract class ActionPlaceOrBreak extends Action {
|
||||
return false;
|
||||
}*/
|
||||
if (Baritone.whatAreYouLookingAt() != null) {
|
||||
Baritone.switchtotool(Minecraft.getMinecraft().world.getBlockState(Baritone.whatAreYouLookingAt()).getBlock());
|
||||
Baritone.switchtotool(Baritone.get(Baritone.whatAreYouLookingAt()).getBlock());
|
||||
}
|
||||
MovementManager.isLeftClick = true;//hold down left click
|
||||
if (canWalkThrough(positionsToBreak[i])) {
|
||||
@ -153,19 +163,21 @@ public abstract class ActionPlaceOrBreak extends Action {
|
||||
}
|
||||
//I dont want to make this static, because then it might be executed before Item gets initialized
|
||||
private static List<Item> ACCEPTABLE_THROWAWAY_ITEMS = null;
|
||||
|
||||
private static void set() {
|
||||
if (ACCEPTABLE_THROWAWAY_ITEMS != null) {
|
||||
return;
|
||||
}
|
||||
ACCEPTABLE_THROWAWAY_ITEMS = Arrays.asList(new Item[]{Item.getByNameOrId("minecraft:dirt"), Item.getByNameOrId("minecraft:cobblestone")});
|
||||
}
|
||||
|
||||
public static boolean switchtothrowaway(boolean message) {
|
||||
set();
|
||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||
ItemStack[] inv = p.inventory.mainInventory;
|
||||
NonNullList<ItemStack> inv = p.inventory.mainInventory;
|
||||
for (byte i = 0; i < 9; i++) {
|
||||
ItemStack item = inv[i];
|
||||
if (inv[i] == null) {
|
||||
ItemStack item = inv.get(i);
|
||||
if (item == null) {
|
||||
item = new ItemStack(Item.getByNameOrId("minecraft:apple"));
|
||||
}
|
||||
if (ACCEPTABLE_THROWAWAY_ITEMS.contains(item.getItem())) {
|
||||
@ -178,13 +190,14 @@ public abstract class ActionPlaceOrBreak extends Action {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasthrowaway() {
|
||||
set();
|
||||
EntityPlayerSP p = Minecraft.getMinecraft().player;
|
||||
ItemStack[] inv = p.inventory.mainInventory;
|
||||
NonNullList<ItemStack> inv = p.inventory.mainInventory;
|
||||
for (byte i = 0; i < 9; i++) {
|
||||
ItemStack item = inv[i];
|
||||
if (inv[i] == null) {
|
||||
ItemStack item = inv.get(i);
|
||||
if (item == null) {
|
||||
item = new ItemStack(Item.getByNameOrId("minecraft:apple"));
|
||||
}
|
||||
if (ACCEPTABLE_THROWAWAY_ITEMS.contains(item.getItem())) {
|
||||
@ -193,6 +206,7 @@ public abstract class ActionPlaceOrBreak extends Action {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the actual tick. This function can assume that all blocks in
|
||||
* positionsToBreak are now walk-through-able.
|
||||
@ -200,6 +214,7 @@ public abstract class ActionPlaceOrBreak extends Action {
|
||||
* @return
|
||||
*/
|
||||
protected abstract boolean tick0();
|
||||
|
||||
public ArrayList<BlockPos> toMine() {
|
||||
ArrayList<BlockPos> result = new ArrayList<>();
|
||||
for (BlockPos positionsToBreak1 : positionsToBreak) {
|
||||
@ -209,6 +224,7 @@ public abstract class ActionPlaceOrBreak extends Action {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ArrayList<BlockPos> toPlace() {
|
||||
ArrayList<BlockPos> result = new ArrayList<>();
|
||||
for (BlockPos positionsToPlace1 : positionsToPlace) {
|
||||
|
@ -5,8 +5,8 @@
|
||||
*/
|
||||
package baritone.pathfinding.goals;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.pathfinding.actions.Action;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
@ -14,27 +14,34 @@ import net.minecraft.util.math.BlockPos;
|
||||
* @author leijurv
|
||||
*/
|
||||
public class GoalBlock implements Goal {
|
||||
|
||||
final int x, y, z;
|
||||
|
||||
public GoalBlock() {
|
||||
this(Minecraft.getMinecraft().player.playerFeet());
|
||||
this(Baritone.playerFeet);
|
||||
}
|
||||
|
||||
public GoalBlock(BlockPos pos) {
|
||||
this(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
public GoalBlock(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public BlockPos pos() {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInGoal(BlockPos pos) {
|
||||
return pos.getX() == this.x && pos.getY() == this.y && pos.getZ() == this.z;
|
||||
}
|
||||
static final double MIN = 20;
|
||||
static final double MAX = 150;
|
||||
|
||||
@Override
|
||||
public double heuristic(BlockPos pos) {
|
||||
double xDiff = pos.getX() - this.x;
|
||||
@ -42,6 +49,7 @@ public class GoalBlock implements Goal {
|
||||
double zDiff = pos.getZ() - this.z;
|
||||
return calculate(xDiff, yDiff, zDiff);
|
||||
}
|
||||
|
||||
public static double calculate(double xDiff, double yDiff, double zDiff) {
|
||||
double pythaDist = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
|
||||
double heuristic = 0;
|
||||
@ -61,6 +69,7 @@ public class GoalBlock implements Goal {
|
||||
heuristic += GoalXZ.calculate(xDiff, zDiff, pythaDist);
|
||||
return heuristic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Goal{x=" + x + ",y=" + y + ",z=" + z + "}";
|
||||
|
@ -5,25 +5,29 @@
|
||||
*/
|
||||
package baritone.pathfinding.goals;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import baritone.Baritone;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author avecowa
|
||||
*/
|
||||
public class GoalGetToBlock extends GoalComposite{
|
||||
public class GoalGetToBlock extends GoalComposite {
|
||||
|
||||
public static BlockPos goalPos;
|
||||
|
||||
public GoalGetToBlock(BlockPos pos) {
|
||||
super(ajacentBlocks(goalPos = pos));
|
||||
}
|
||||
public GoalGetToBlock(){
|
||||
|
||||
public GoalGetToBlock() {
|
||||
this(Baritone.playerFeet);
|
||||
}
|
||||
public static BlockPos[] ajacentBlocks(BlockPos pos){
|
||||
|
||||
public static BlockPos[] ajacentBlocks(BlockPos pos) {
|
||||
BlockPos[] sides = new BlockPos[6];
|
||||
for(int i = 0; i < 6; i++){
|
||||
for (int i = 0; i < 6; i++) {
|
||||
sides[i] = pos.offset(EnumFacing.values()[i]);
|
||||
}
|
||||
return sides;
|
||||
|
@ -50,7 +50,7 @@ public class SchematicBuilder {
|
||||
for (int z = 0; z < schematic.getLength(); z++) {
|
||||
BlockPos inSchematic = new BlockPos(x, y, z);
|
||||
BlockPos inWorld = offset(inSchematic);
|
||||
Block current = Minecraft.getMinecraft().world.getBlockState(inWorld).getBlock();
|
||||
Block current = Baritone.get(inWorld).getBlock();
|
||||
Block desired = schematic.getBlockFromBlockPos(inSchematic);
|
||||
//Out.log(inSchematic + " " + current + " " + desired);
|
||||
boolean currentlyAir = air.equals(current);
|
||||
|
@ -1,153 +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.ui;
|
||||
|
||||
import baritone.aiming.Arrow;
|
||||
import baritone.aiming.Constants;
|
||||
import baritone.aiming.Helper;
|
||||
import baritone.ui.LookManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBow;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.Color;
|
||||
import org.lwjgl.util.ReadableColor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author galdara
|
||||
*/
|
||||
public class AimBow {
|
||||
public static BlockPos lastBlock = null;
|
||||
public static boolean canHit(BlockPos target) {
|
||||
return false;
|
||||
}
|
||||
public static void render(EntityPlayer player, float partialTicks) {
|
||||
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemBow) {
|
||||
drawArrowArc(player, new Arrow(Constants.BowConstants.bowFullDraw, Helper.degreesToRadians(player.rotationPitch * -1)), Color.BLUE, Color.RED, partialTicks);
|
||||
} else {
|
||||
lastBlock = null;
|
||||
}
|
||||
}
|
||||
public static void drawArrowArc(EntityPlayer player, Arrow arrow, ReadableColor airColor, ReadableColor liquidColor, float partialTicks) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GL11.glLineWidth(0.5F);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
GlStateManager.color(airColor.getRed(), airColor.getGreen(), airColor.getBlue());
|
||||
double previousDist = 0;
|
||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks;
|
||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
|
||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;
|
||||
double previousX = d0 + previousDist - (double) (Math.cos(Helper.degreesToRadians(player.rotationYaw)) * 0.16F);
|
||||
double previousY = arrow.getVerticalPositionAtHorizontalPosition(previousDist) + d1 + (double) player.getEyeHeight() - 0.10000000149011612D;;
|
||||
double previousZ = d2 + previousDist - (double) (Math.sin(Helper.degreesToRadians(player.rotationYaw)) * 0.16F);
|
||||
for (double dist = Constants.BowConstants.renderTrajectoryIncrement; dist < Constants.BowConstants.renderTrajectoryCutoff; dist += Constants.BowConstants.renderTrajectoryIncrement) {
|
||||
BlockPos blockPos = new BlockPos(previousX, previousY, previousZ);
|
||||
IBlockState blockState = Minecraft.getMinecraft().world.getBlockState(blockPos);
|
||||
Block block = blockState.getBlock();
|
||||
if (Constants.BlockConstants.materialsPassable.contains(block.getMaterial())) {
|
||||
if (Constants.BlockConstants.materialsLiquid.contains(block.getMaterial()) && arrow.isInAir) {
|
||||
arrow.setIsInAir(false);
|
||||
GlStateManager.color(liquidColor.getRed(), liquidColor.getGreen(), liquidColor.getBlue());
|
||||
} else if (!arrow.isInAir) {
|
||||
arrow.setIsInAir(true);
|
||||
GlStateManager.color(airColor.getRed(), airColor.getGreen(), airColor.getBlue());
|
||||
}
|
||||
double currentX = (-Math.sin(Helper.degreesToRadians(player.rotationYaw)) * dist) + d0 - (double) (Math.cos((float) Helper.degreesToRadians(player.rotationYaw)) * 0.16F);
|
||||
double currentY = arrow.getVerticalPositionAtHorizontalPosition(dist) + d1 + (double) player.getEyeHeight() - 0.10000000149011612D;
|
||||
double currentZ = (Math.cos(Helper.degreesToRadians(player.rotationYaw)) * dist) + d2 - (double) (Math.sin((float) Helper.degreesToRadians(player.rotationYaw)) * 0.16F);
|
||||
drawLine(player, previousX, previousY, previousZ, currentX, currentY, currentZ, partialTicks);
|
||||
previousX = currentX;
|
||||
previousY = currentY;
|
||||
previousZ = currentZ;
|
||||
} else {
|
||||
drawSelectionBox(player, blockPos, partialTicks, (arrow.isInAir ? airColor : liquidColor));
|
||||
AimBow.lastBlock = blockPos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
public static void drawLine(EntityPlayer player, double bp1x, double bp1y, double bp1z, double bp2x, double bp2y, double bp2z, float partialTicks) {
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks;
|
||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
|
||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;
|
||||
worldrenderer.begin(3, DefaultVertexFormats.POSITION);
|
||||
worldrenderer.pos(bp1x - d0, bp1y - d1, bp1z - d2).endVertex();
|
||||
worldrenderer.pos(bp2x - d0, bp2y - d1, bp2z - d2).endVertex();
|
||||
worldrenderer.pos(bp2x - d0, bp2y - d1, bp2z - d2).endVertex();
|
||||
worldrenderer.pos(bp1x - d0, bp1y - d1, bp1z - d2).endVertex();
|
||||
worldrenderer.pos(bp1x - d0, bp1y - d1, bp1z - d2).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
public static void drawSelectionBox(EntityPlayer player, BlockPos blockpos, float partialTicks, ReadableColor color) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.color(color.getRed(), color.getGreen(), color.getBlue(), 0.4F);
|
||||
GL11.glLineWidth(5.0F);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
float f = 0.002F;
|
||||
//BlockPos blockpos = movingObjectPositionIn.getBlockPos();
|
||||
Block block = Minecraft.getMinecraft().world.getBlockState(blockpos).getBlock();
|
||||
if (block.equals(Blocks.air)) {
|
||||
block = Blocks.dirt;
|
||||
}
|
||||
block.setBlockBoundsBasedOnState(Minecraft.getMinecraft().world, blockpos);
|
||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks;
|
||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
|
||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;
|
||||
AxisAlignedBB toDraw = block.getSelectedBoundingBox(Minecraft.getMinecraft().world, blockpos).expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
||||
worldrenderer.begin(3, DefaultVertexFormats.POSITION);
|
||||
worldrenderer.pos(toDraw.minX, toDraw.minY, toDraw.minZ).endVertex();
|
||||
worldrenderer.pos(toDraw.maxX, toDraw.minY, toDraw.minZ).endVertex();
|
||||
worldrenderer.pos(toDraw.maxX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||
worldrenderer.pos(toDraw.minX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||
worldrenderer.pos(toDraw.minX, toDraw.minY, toDraw.minZ).endVertex();
|
||||
tessellator.draw();
|
||||
worldrenderer.begin(3, DefaultVertexFormats.POSITION);
|
||||
worldrenderer.pos(toDraw.minX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||
worldrenderer.pos(toDraw.maxX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||
worldrenderer.pos(toDraw.maxX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||
worldrenderer.pos(toDraw.minX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||
worldrenderer.pos(toDraw.minX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||
tessellator.draw();
|
||||
worldrenderer.begin(1, DefaultVertexFormats.POSITION);
|
||||
worldrenderer.pos(toDraw.minX, toDraw.minY, toDraw.minZ).endVertex();
|
||||
worldrenderer.pos(toDraw.minX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||
worldrenderer.pos(toDraw.maxX, toDraw.minY, toDraw.minZ).endVertex();
|
||||
worldrenderer.pos(toDraw.maxX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||
worldrenderer.pos(toDraw.maxX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||
worldrenderer.pos(toDraw.maxX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||
worldrenderer.pos(toDraw.minX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||
worldrenderer.pos(toDraw.minX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
public static void aimAtEntity(Entity entity) {
|
||||
LookManager.setDesiredYaw((float) Math.atan2(entity.posX - Minecraft.getMinecraft().player.posX, entity.posZ - Minecraft.getMinecraft().player.posZ));
|
||||
}
|
||||
}
|
@ -86,7 +86,7 @@ public class LookManager extends Manager {
|
||||
if (couldIReachCenter(p)) {
|
||||
return lookAtCenterOfBlock(p, alsoDoPitch);
|
||||
}
|
||||
Block b = Minecraft.getMinecraft().world.getBlockState(p).getBlock();
|
||||
Block b = Baritone.get(p).getBlock();
|
||||
for (double[] mult : BLOCK_SIDE_MULTIPLIERS) {
|
||||
double xDiff = b.getBlockBoundsMinX() * mult[0] + b.getBlockBoundsMaxX() * (1 - mult[0]);//lol
|
||||
double yDiff = b.getBlockBoundsMinY() * mult[1] + b.getBlockBoundsMaxY() * (1 - mult[1]);
|
||||
@ -101,7 +101,7 @@ public class LookManager extends Manager {
|
||||
return lookAtCenterOfBlock(p, alsoDoPitch);
|
||||
}
|
||||
public static boolean lookAtCenterOfBlock(BlockPos p, boolean alsoDoPitch) {
|
||||
Block b = Minecraft.getMinecraft().world.getBlockState(p).getBlock();
|
||||
Block b = Baritone.get(p).getBlock();
|
||||
double xDiff = (b.getBlockBoundsMinX() + b.getBlockBoundsMaxX()) / 2;
|
||||
double yDiff = (b.getBlockBoundsMinY() + b.getBlockBoundsMaxY()) / 2;
|
||||
double zDiff = (b.getBlockBoundsMinZ() + b.getBlockBoundsMaxZ()) / 2;
|
||||
@ -121,7 +121,7 @@ public class LookManager extends Manager {
|
||||
if (couldIReachCenter(pos)) {
|
||||
return true;
|
||||
}
|
||||
Block b = Minecraft.getMinecraft().world.getBlockState(pos).getBlock();
|
||||
Block b = Baritone.get(pos).getBlock();
|
||||
for (double[] mult : BLOCK_SIDE_MULTIPLIERS) {
|
||||
double xDiff = b.getBlockBoundsMinX() * mult[0] + b.getBlockBoundsMaxX() * (1 - mult[0]);
|
||||
double yDiff = b.getBlockBoundsMinY() * mult[1] + b.getBlockBoundsMaxY() * (1 - mult[1]);
|
||||
@ -203,7 +203,7 @@ public class LookManager extends Manager {
|
||||
return new float[]{first, second};
|
||||
}
|
||||
public static float[] pitchAndYawToCenter(BlockPos p) {
|
||||
Block b = Minecraft.getMinecraft().world.getBlockState(p).getBlock();
|
||||
Block b = Baritone.get(p).getBlock();
|
||||
double xDiff = (b.getBlockBoundsMinX() + b.getBlockBoundsMaxX()) / 2;
|
||||
double yolo = (b.getBlockBoundsMinY() + b.getBlockBoundsMaxY()) / 2;
|
||||
double zDiff = (b.getBlockBoundsMinZ() + b.getBlockBoundsMaxZ()) / 2;
|
||||
|
@ -206,7 +206,7 @@ public class PathRenderer {
|
||||
GlStateManager.depthMask(false);
|
||||
float f = 0.002F;
|
||||
//BlockPos blockpos = movingObjectPositionIn.getBlockPos();
|
||||
Block block = Minecraft.getMinecraft().world.getBlockState(blockpos).getBlock();
|
||||
Block block = Baritone.get(blockpos).getBlock();
|
||||
if (block.equals(Blocks.air)) {
|
||||
block = Blocks.dirt;
|
||||
}
|
||||
|
@ -1,257 +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.ui;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import baritone.util.Manager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
/**
|
||||
* I swear, this *isn't* copied from net.minecraft.util.ScreenShotHelper. Pinky
|
||||
* promise.
|
||||
*
|
||||
* @author leijurv
|
||||
*/
|
||||
public class Screenshot extends Manager {
|
||||
static ExecutorService lol = Executors.newCachedThreadPool();
|
||||
|
||||
public static class Dank<E> {
|
||||
E curr;
|
||||
Dank<E> next;
|
||||
}
|
||||
static final Object valCacheLock = new Object();
|
||||
static Dank<int[]> valCache = null;
|
||||
public static int[] getInt(int size) {
|
||||
while (true) {
|
||||
int[] blah = popInt();
|
||||
if (blah == null) {
|
||||
System.out.println("CREATING INT ARRAY OF SIZE " + size);
|
||||
return new int[size];
|
||||
}
|
||||
if (blah.length >= size) {
|
||||
if (blah.length > size) {
|
||||
if (new Random().nextInt(100) == 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return blah;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void pushInt(int[] blah) {
|
||||
synchronized (valCacheLock) {
|
||||
Dank<int[]> xd = new Dank<>();
|
||||
xd.next = valCache;
|
||||
xd.curr = blah;
|
||||
valCache = xd;
|
||||
}
|
||||
}
|
||||
public static int[] popInt() {
|
||||
synchronized (valCacheLock) {
|
||||
if (valCache == null) {
|
||||
return null;
|
||||
}
|
||||
int[] result = valCache.curr;
|
||||
valCache = valCache.next;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
static final Object bufCacheLock = new Object();
|
||||
static Dank<IntBuffer> bufCache = null;
|
||||
public static IntBuffer getBuf(int size) {
|
||||
while (true) {
|
||||
IntBuffer blah = popBuf();
|
||||
if (blah == null) {
|
||||
System.out.println("CREATING INT BUFFER OF SIZE " + size);
|
||||
return BufferUtils.createIntBuffer(size);
|
||||
}
|
||||
if (blah.capacity() >= size) {
|
||||
if (blah.capacity() > size) {
|
||||
if (new Random().nextInt(100) == 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return blah;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void pushBuf(IntBuffer blah) {
|
||||
blah.clear();
|
||||
synchronized (bufCacheLock) {
|
||||
Dank<IntBuffer> xd = new Dank<>();
|
||||
xd.next = bufCache;
|
||||
xd.curr = blah;
|
||||
bufCache = xd;
|
||||
}
|
||||
}
|
||||
public static IntBuffer popBuf() {
|
||||
synchronized (bufCacheLock) {
|
||||
if (bufCache == null) {
|
||||
return null;
|
||||
}
|
||||
IntBuffer result = bufCache.curr;
|
||||
bufCache = bufCache.next;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public static void screenshot() {
|
||||
if (currPixVal != null) {
|
||||
System.out.println("Skipping");
|
||||
return;
|
||||
}
|
||||
int width = Minecraft.getMinecraft().displayWidth;
|
||||
int height = Minecraft.getMinecraft().displayHeight;
|
||||
int i = width * height;
|
||||
final IntBuffer pixelBuffer = getBuf(i);
|
||||
GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
|
||||
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
|
||||
GL11.glReadPixels(0, 0, width, height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
int[] pixelValues = getInt(i);
|
||||
pixelBuffer.get(pixelValues);
|
||||
TextureUtil.processPixelValues(pixelValues, width, height);
|
||||
/*BufferedImage bufferedimage;
|
||||
bufferedimage = new BufferedImage(width, height, 1);
|
||||
bufferedimage.setRGB(0, 0, width, height, pixelValues, 0, width);*/
|
||||
pushBuf(pixelBuffer);
|
||||
boolean hasSockets;
|
||||
synchronized (socketsLock) {
|
||||
hasSockets = !sockets.isEmpty();
|
||||
}
|
||||
if (!hasSockets) {
|
||||
pushInt(pixelValues);
|
||||
return;
|
||||
}
|
||||
synchronized (currPixLock) {
|
||||
if (currPixVal != null) {
|
||||
pushInt(currPixVal);
|
||||
}
|
||||
currPixVal = pixelValues;
|
||||
currWidth = width;
|
||||
currHeight = height;
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
static final Object currPixLock = new Object();
|
||||
static int[] currPixVal = null;
|
||||
static int currWidth = 0;
|
||||
static int currHeight = 0;
|
||||
@Override
|
||||
protected void onTick() {
|
||||
boolean hasSockets;
|
||||
synchronized (socketsLock) {
|
||||
hasSockets = !sockets.isEmpty();
|
||||
}
|
||||
if (hasSockets) {
|
||||
long bef = System.currentTimeMillis();
|
||||
screenshot();
|
||||
long aft = System.currentTimeMillis();
|
||||
if (aft != bef) {
|
||||
System.out.println("Took " + (aft - bef));
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onCancel() {
|
||||
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
static final Object socketsLock = new Object();
|
||||
static ArrayList<Socket> sockets = new ArrayList<>();
|
||||
@Override
|
||||
protected void onStart() {
|
||||
try {
|
||||
ServerSocket blah = new ServerSocket(5021);
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while (true) {
|
||||
Thread.sleep(100);
|
||||
synchronized (socketsLock) {
|
||||
if (sockets.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
int width;
|
||||
int height;
|
||||
int[] pixelValues;
|
||||
synchronized (currPixLock) {
|
||||
if (currPixVal == null) {
|
||||
continue;
|
||||
}
|
||||
width = currWidth;
|
||||
height = currHeight;
|
||||
pixelValues = currPixVal;
|
||||
currPixVal = null;
|
||||
}
|
||||
ArrayList<Socket> tmpCopy;
|
||||
synchronized (socketsLock) {
|
||||
tmpCopy = sockets;
|
||||
}
|
||||
for (Socket socket : tmpCopy) {
|
||||
try {
|
||||
long start = System.currentTimeMillis();
|
||||
OutputStream o = socket.getOutputStream();
|
||||
System.out.println("Write " + width + " " + height + " " + pixelValues.length);
|
||||
new DataOutputStream(o).writeInt(width);
|
||||
new DataOutputStream(o).writeInt(height);
|
||||
new ObjectOutputStream(o).writeObject(pixelValues);
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println("Written in " + (end - start));
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Screenshot.class.getName()).log(Level.SEVERE, null, ex);
|
||||
synchronized (socketsLock) {
|
||||
sockets.remove(socket);
|
||||
}
|
||||
}
|
||||
}
|
||||
pushInt(pixelValues);
|
||||
}
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(Screenshot.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while (true) {
|
||||
Socket socket = blah.accept();
|
||||
synchronized (socketsLock) {
|
||||
sockets.add(socket);
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Screenshot.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Screenshot.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,343 +0,0 @@
|
||||
package baritone.util;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.IProjectile;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class FakeArrow extends Entity implements IProjectile {
|
||||
private int xTile = -1;
|
||||
private int yTile = -1;
|
||||
private int zTile = -1;
|
||||
private Block inTile;
|
||||
private int inData;
|
||||
private boolean inGround;
|
||||
/**
|
||||
* 1 if the player can pick up the arrow
|
||||
*/
|
||||
public int canBePickedUp;
|
||||
/**
|
||||
* Seems to be some sort of timer for animating an arrow.
|
||||
*/
|
||||
public int arrowShake;
|
||||
/**
|
||||
* The owner of this arrow.
|
||||
*/
|
||||
public Entity shootingEntity;
|
||||
public boolean didIHitAnEntity = false;
|
||||
private int ticksInGround;
|
||||
private int ticksInAir;
|
||||
private double damage = 2.0D;
|
||||
/**
|
||||
* The amount of knockback an arrow applies when it hits a mob.
|
||||
*/
|
||||
private int knockbackStrength;
|
||||
public FakeArrow(World worldIn, EntityLivingBase shooter, float velocity, float partialTucks) {
|
||||
super(worldIn);
|
||||
double d0 = shooter.lastTickPosX + (shooter.posX - shooter.lastTickPosX) * (double) partialTucks;
|
||||
double d1 = shooter.lastTickPosY + (shooter.posY - shooter.lastTickPosY) * (double) partialTucks;
|
||||
double d2 = shooter.lastTickPosZ + (shooter.posZ - shooter.lastTickPosZ) * (double) partialTucks;
|
||||
this.renderDistanceWeight = 10.0D;
|
||||
this.shootingEntity = shooter;
|
||||
if (shooter instanceof EntityPlayer) {
|
||||
this.canBePickedUp = 1;
|
||||
}
|
||||
this.setSize(0.5F, 0.5F);
|
||||
this.setLocationAndAngles(d0, d1 + (double) shooter.getEyeHeight(), d2, shooter.rotationYaw, shooter.rotationPitch);
|
||||
this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
|
||||
this.posY -= 0.10000000149011612D;
|
||||
this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F);
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.motionX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
|
||||
this.motionZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI));
|
||||
this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI));
|
||||
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, velocity * 1.5F, 1.0F);
|
||||
}
|
||||
protected void entityInit() {
|
||||
this.dataWatcher.addObject(16, Byte.valueOf((byte) 0));
|
||||
}
|
||||
/**
|
||||
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z
|
||||
* direction.
|
||||
*/
|
||||
public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) {
|
||||
float f = MathHelper.sqrt_double(x * x + y * y + z * z);
|
||||
x = x / (double) f;
|
||||
y = y / (double) f;
|
||||
z = z / (double) f;
|
||||
//x = x + this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) inaccuracy;
|
||||
//y = y + this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) inaccuracy;
|
||||
//z = z + this.rand.nextGaussian() * (double) (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double) inaccuracy;
|
||||
x = x * (double) velocity;
|
||||
y = y * (double) velocity;
|
||||
z = z * (double) velocity;
|
||||
this.motionX = x;
|
||||
this.motionY = y;
|
||||
this.motionZ = z;
|
||||
float f1 = MathHelper.sqrt_double(x * x + z * z);
|
||||
this.prevRotationYaw = this.rotationYaw = (float) (MathHelper.func_181159_b(x, z) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float) (MathHelper.func_181159_b(y, (double) f1) * 180.0D / Math.PI);
|
||||
this.ticksInGround = 0;
|
||||
}
|
||||
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_) {
|
||||
this.setPosition(x, y, z);
|
||||
this.setRotation(yaw, pitch);
|
||||
}
|
||||
/**
|
||||
* Sets the velocity to the args. Args: x, y, z
|
||||
*/
|
||||
public void setVelocity(double x, double y, double z) {
|
||||
this.motionX = x;
|
||||
this.motionY = y;
|
||||
this.motionZ = z;
|
||||
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
|
||||
float f = MathHelper.sqrt_double(x * x + z * z);
|
||||
this.prevRotationYaw = this.rotationYaw = (float) (MathHelper.func_181159_b(x, z) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float) (MathHelper.func_181159_b(y, (double) f) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch;
|
||||
this.prevRotationYaw = this.rotationYaw;
|
||||
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
|
||||
this.ticksInGround = 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
|
||||
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.prevRotationYaw = this.rotationYaw = (float) (MathHelper.func_181159_b(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float) (MathHelper.func_181159_b(this.motionY, (double) f) * 180.0D / Math.PI);
|
||||
}
|
||||
BlockPos blockpos = new BlockPos(this.xTile, this.yTile, this.zTile);
|
||||
IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
|
||||
Block block = iblockstate.getBlock();
|
||||
if (block.getMaterial() != Material.air) {
|
||||
block.setBlockBoundsBasedOnState(this.worldObj, blockpos);
|
||||
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBox(this.worldObj, blockpos, iblockstate);
|
||||
if (axisalignedbb != null && axisalignedbb.isVecInside(new Vec3(this.posX, this.posY, this.posZ))) {
|
||||
this.inGround = true;
|
||||
}
|
||||
}
|
||||
if (this.arrowShake > 0) {
|
||||
--this.arrowShake;
|
||||
}
|
||||
if (this.inGround) {
|
||||
int j = block.getMetaFromState(iblockstate);
|
||||
if (block == this.inTile && j == this.inData) {
|
||||
++this.ticksInGround;
|
||||
if (this.ticksInGround >= 1200) {
|
||||
this.setDead();
|
||||
}
|
||||
} else {
|
||||
this.inGround = false;
|
||||
this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
|
||||
this.ticksInGround = 0;
|
||||
this.ticksInAir = 0;
|
||||
}
|
||||
} else {
|
||||
++this.ticksInAir;
|
||||
Vec3 vec31 = new Vec3(this.posX, this.posY, this.posZ);
|
||||
Vec3 vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3, false, true, false);
|
||||
vec31 = new Vec3(this.posX, this.posY, this.posZ);
|
||||
vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||
if (movingobjectposition != null) {
|
||||
vec3 = new Vec3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
|
||||
}
|
||||
Entity entity = null;
|
||||
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
double d0 = 0.0D;
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
Entity entity1 = (Entity) list.get(i);
|
||||
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
|
||||
float f1 = 0.3F;
|
||||
AxisAlignedBB axisalignedbb1 = entity1.getEntityBoundingBox().expand((double) f1, (double) f1, (double) f1);
|
||||
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
|
||||
if (movingobjectposition1 != null) {
|
||||
double d1 = vec31.squareDistanceTo(movingobjectposition1.hitVec);
|
||||
if (d1 < d0 || d0 == 0.0D) {
|
||||
entity = entity1;
|
||||
d0 = d1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entity != null) {
|
||||
movingobjectposition = new MovingObjectPosition(entity);
|
||||
}
|
||||
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;
|
||||
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) {
|
||||
movingobjectposition = null;
|
||||
}
|
||||
}
|
||||
if (movingobjectposition != null) {
|
||||
if (movingobjectposition.entityHit != null) {
|
||||
float f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
int l = MathHelper.ceiling_double_int((double) f2 * this.damage);
|
||||
didIHitAnEntity = true;
|
||||
/*if (this.getIsCritical()) {
|
||||
l += this.rand.nextInt(l / 2 + 2);
|
||||
}
|
||||
mageSource damagesource;
|
||||
if (this.shootingEntity == null) {
|
||||
damagesource = DamageSource.causeArrowDamage(this, this);
|
||||
} else {
|
||||
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
|
||||
}
|
||||
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) {
|
||||
movingobjectposition.entityHit.setFire(5);
|
||||
}
|
||||
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float) l)) {
|
||||
if (movingobjectposition.entityHit instanceof EntityLivingBase) {
|
||||
EntityLivingBase entitylivingbase = (EntityLivingBase) movingobjectposition.entityHit;
|
||||
if (!this.worldObj.isRemote) {
|
||||
entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1);
|
||||
}
|
||||
if (this.knockbackStrength > 0) {
|
||||
float f7 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
if (f7 > 0.0F) {
|
||||
movingobjectposition.entityHit.addVelocity(this.motionX * (double) this.knockbackStrength * 0.6000000238418579D / (double) f7, 0.1D, this.motionZ * (double) this.knockbackStrength * 0.6000000238418579D / (double) f7);
|
||||
}
|
||||
}
|
||||
if (this.shootingEntity instanceof EntityLivingBase) {
|
||||
EnchantmentHelper.applyThornEnchantments(entitylivingbase, this.shootingEntity);
|
||||
EnchantmentHelper.applyArthropodEnchantments((EntityLivingBase) this.shootingEntity, entitylivingbase);
|
||||
}
|
||||
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
|
||||
}
|
||||
}
|
||||
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
if (!(movingobjectposition.entityHit instanceof EntityEnderman)) {
|
||||
this.setDead();
|
||||
}
|
||||
} else {
|
||||
this.motionX *= -0.10000000149011612D;
|
||||
this.motionY *= -0.10000000149011612D;
|
||||
this.motionZ *= -0.10000000149011612D;
|
||||
this.rotationYaw += 180.0F;
|
||||
this.prevRotationYaw += 180.0F;
|
||||
this.ticksInAir = 0;
|
||||
}*/
|
||||
} else {
|
||||
BlockPos blockpos1 = movingobjectposition.getBlockPos();
|
||||
this.xTile = blockpos1.getX();
|
||||
this.yTile = blockpos1.getY();
|
||||
this.zTile = blockpos1.getZ();
|
||||
IBlockState iblockstate1 = this.worldObj.getBlockState(blockpos1);
|
||||
this.inTile = iblockstate1.getBlock();
|
||||
this.inData = this.inTile.getMetaFromState(iblockstate1);
|
||||
this.motionX = (double) ((float) (movingobjectposition.hitVec.xCoord - this.posX));
|
||||
this.motionY = (double) ((float) (movingobjectposition.hitVec.yCoord - this.posY));
|
||||
this.motionZ = (double) ((float) (movingobjectposition.hitVec.zCoord - this.posZ));
|
||||
float f5 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||
this.posX -= this.motionX / (double) f5 * 0.05000000074505806D;
|
||||
this.posY -= this.motionY / (double) f5 * 0.05000000074505806D;
|
||||
this.posZ -= this.motionZ / (double) f5 * 0.05000000074505806D;
|
||||
//this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
this.inGround = true;
|
||||
this.arrowShake = 7;
|
||||
if (this.inTile.getMaterial() != Material.air) {
|
||||
this.inTile.onEntityCollidedWithBlock(this.worldObj, blockpos1, iblockstate1, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.posX += this.motionX;
|
||||
this.posY += this.motionY;
|
||||
this.posZ += this.motionZ;
|
||||
float f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
this.rotationYaw = (float) (MathHelper.func_181159_b(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||
for (this.rotationPitch = (float) (MathHelper.func_181159_b(this.motionY, (double) f3) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
|
||||
;
|
||||
}
|
||||
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
|
||||
this.prevRotationPitch += 360.0F;
|
||||
}
|
||||
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
|
||||
this.prevRotationYaw -= 360.0F;
|
||||
}
|
||||
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
|
||||
this.prevRotationYaw += 360.0F;
|
||||
}
|
||||
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
|
||||
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
|
||||
float f4 = 0.99F;
|
||||
float f6 = 0.05F;
|
||||
if (this.isInWater()) {
|
||||
for (int i1 = 0; i1 < 4; ++i1) {
|
||||
float f8 = 0.25F;
|
||||
this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double) f8, this.posY - this.motionY * (double) f8, this.posZ - this.motionZ * (double) f8, this.motionX, this.motionY, this.motionZ, new int[0]);
|
||||
}
|
||||
f4 = 0.6F;
|
||||
}
|
||||
if (this.isWet()) {
|
||||
this.extinguish();
|
||||
}
|
||||
this.motionX *= (double) f4;
|
||||
this.motionY *= (double) f4;
|
||||
this.motionZ *= (double) f4;
|
||||
this.motionY -= (double) f6;
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
this.doBlockCollisions();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* (abstract) Protected helper method to write subclass entity data to NBT.
|
||||
*/
|
||||
public void writeEntityToNBT(NBTTagCompound tagCompound) {
|
||||
tagCompound.setShort("xTile", (short) this.xTile);
|
||||
tagCompound.setShort("yTile", (short) this.yTile);
|
||||
tagCompound.setShort("zTile", (short) this.zTile);
|
||||
tagCompound.setShort("life", (short) this.ticksInGround);
|
||||
ResourceLocation resourcelocation = (ResourceLocation) Block.blockRegistry.getNameForObject(this.inTile);
|
||||
tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
|
||||
tagCompound.setByte("inData", (byte) this.inData);
|
||||
tagCompound.setByte("shake", (byte) this.arrowShake);
|
||||
tagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0));
|
||||
tagCompound.setByte("pickup", (byte) this.canBePickedUp);
|
||||
tagCompound.setDouble("damage", this.damage);
|
||||
}
|
||||
/**
|
||||
* (abstract) Protected helper method to read subclass entity data from NBT.
|
||||
*/
|
||||
public void readEntityFromNBT(NBTTagCompound tagCompund) {
|
||||
this.xTile = tagCompund.getShort("xTile");
|
||||
this.yTile = tagCompund.getShort("yTile");
|
||||
this.zTile = tagCompund.getShort("zTile");
|
||||
this.ticksInGround = tagCompund.getShort("life");
|
||||
if (tagCompund.hasKey("inTile", 8)) {
|
||||
this.inTile = Block.getBlockFromName(tagCompund.getString("inTile"));
|
||||
} else {
|
||||
this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255);
|
||||
}
|
||||
this.inData = tagCompund.getByte("inData") & 255;
|
||||
this.arrowShake = tagCompund.getByte("shake") & 255;
|
||||
this.inGround = tagCompund.getByte("inGround") == 1;
|
||||
if (tagCompund.hasKey("damage", 99)) {
|
||||
this.damage = tagCompund.getDouble("damage");
|
||||
}
|
||||
if (tagCompund.hasKey("pickup", 99)) {
|
||||
this.canBePickedUp = tagCompund.getByte("pickup");
|
||||
} else if (tagCompund.hasKey("player", 99)) {
|
||||
this.canBePickedUp = tagCompund.getBoolean("player") ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ public class MCEdit extends Manager {
|
||||
for (int y = Math.max(pos1.getY(), pos2.getY()); y >= Math.min(pos1.getY(), pos2.getY()); y--) {
|
||||
for (int z = Math.min(pos1.getZ(), pos2.getZ()); z <= Math.max(pos1.getZ(), pos2.getZ()); z++) {
|
||||
BlockPos po = new BlockPos(x, y, z);
|
||||
Block b = Minecraft.getMinecraft().world.getBlockState(po).getBlock();
|
||||
Block b = Baritone.get(po).getBlock();
|
||||
if (!Blocks.air.equals(b)) {
|
||||
toBreak.add(po);
|
||||
if (toBreak.size() > 20) {
|
||||
|
@ -67,7 +67,7 @@ public class Memory extends Manager {
|
||||
if (!loaded) {
|
||||
//Out.gui("Too far away from " + pos + " to remember that it's " + block, true);
|
||||
}
|
||||
Block current = Minecraft.getMinecraft().world.getBlockState(pos).getBlock();
|
||||
Block current = Baritone.get(pos).getBlock();
|
||||
if (!current.equals(block) || !loaded) {
|
||||
//Out.gui("Block at " + pos + " has changed from " + block + " to " + current + ". Removing from memory.", true);
|
||||
knownPositions.remove(pos);
|
||||
@ -106,7 +106,7 @@ public class Memory extends Manager {
|
||||
if (!blockLoaded(pos)) {
|
||||
continue;
|
||||
}
|
||||
if (!block.equals(Minecraft.getMinecraft().world.getBlockState(pos).getBlock())) {
|
||||
if (!block.equals(Baritone.get(pos).getBlock())) {
|
||||
continue;
|
||||
}
|
||||
double d = distSq(pos);
|
||||
@ -256,9 +256,9 @@ public class Memory extends Manager {
|
||||
String lower = "block{minecraft:" + b.toLowerCase() + "}";
|
||||
if (type.toString().toLowerCase().equals(lower)) {
|
||||
for (BlockPos pos : blockMemory.get(type).knownPositions) {
|
||||
if (type.equals(Minecraft.getMinecraft().world.getBlockState(pos).getBlock()) && !result.contains(pos)) {
|
||||
if (type.equals(Baritone.get(pos).getBlock()) && !result.contains(pos)) {
|
||||
if (b.equals("stone")) {
|
||||
if (!type.getItemDropped(Minecraft.getMinecraft().world.getBlockState(pos), new Random(), 0).equals(Item.getByNameOrId("cobblestone"))) {
|
||||
if (!type.getItemDropped(Baritone.get(pos), new Random(), 0).equals(Item.getByNameOrId("cobblestone"))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -342,7 +342,7 @@ public class Memory extends Manager {
|
||||
}
|
||||
public static final int SCAN_DIST = 50;
|
||||
public static void scanBlock(BlockPos pos) {
|
||||
Block block = Minecraft.getMinecraft().world.getBlockState(pos).getBlock();
|
||||
Block block = Baritone.get(pos).getBlock();
|
||||
if (air.equals(block)) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user