Merge branch 'master' of github.com:cabaletta/baritone
This commit is contained in:
commit
6d78b7f083
@ -21,6 +21,7 @@ import baritone.bot.behavior.Behavior;
|
||||
import baritone.bot.behavior.impl.LookBehavior;
|
||||
import baritone.bot.behavior.impl.MemoryBehavior;
|
||||
import baritone.bot.behavior.impl.PathingBehavior;
|
||||
import baritone.bot.event.GameEventHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -25,9 +25,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This serves as a replacement to the old {@code MovementManager}'s
|
||||
* input overriding capabilities. It is vastly more extensible in the
|
||||
* inputs that can be overriden.
|
||||
* An interface with the game's control system allowing the ability to
|
||||
* force down certain controls, having the same effect as if we were actually
|
||||
* physically forcing down the assigned key.
|
||||
*
|
||||
* @author Brady
|
||||
* @since 7/31/2018 11:20 PM
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package baritone.bot.behavior;
|
||||
|
||||
import baritone.bot.event.AbstractGameEventListener;
|
||||
import baritone.bot.event.listener.AbstractGameEventListener;
|
||||
import baritone.bot.utils.Helper;
|
||||
|
||||
/**
|
||||
|
@ -63,8 +63,7 @@ public final class CachedChunk implements IBlockTypeAccess {
|
||||
private final BitSet data;
|
||||
|
||||
CachedChunk(int x, int z, BitSet data) {
|
||||
if (data.size() > SIZE)
|
||||
throw new IllegalArgumentException("BitSet of invalid length provided");
|
||||
validateSize(data);
|
||||
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
@ -78,8 +77,7 @@ public final class CachedChunk implements IBlockTypeAccess {
|
||||
}
|
||||
|
||||
void updateContents(BitSet data) {
|
||||
if (data.size() > SIZE)
|
||||
throw new IllegalArgumentException("BitSet of invalid length provided");
|
||||
validateSize(data);
|
||||
|
||||
for (int i = 0; i < data.length(); i++)
|
||||
this.data.set(i, data.get(i));
|
||||
@ -117,4 +115,17 @@ public final class CachedChunk implements IBlockTypeAccess {
|
||||
public static int getPositionIndex(int x, int y, int z) {
|
||||
return (x + (z << 4) + (y << 8)) * 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the size of an input {@link BitSet} containing the raw
|
||||
* packed chunk data. Sizes that exceed {@link CachedChunk#SIZE} are
|
||||
* considered invalid, and thus, an exception will be thrown.
|
||||
*
|
||||
* @param data The raw data
|
||||
* @throws IllegalArgumentException if the bitset size exceeds the maximum size
|
||||
*/
|
||||
private static void validateSize(BitSet data) {
|
||||
if (data.size() > SIZE)
|
||||
throw new IllegalArgumentException("BitSet of invalid length provided");
|
||||
}
|
||||
}
|
||||
|
28
src/main/java/baritone/bot/GameEventHandler.java → src/main/java/baritone/bot/event/GameEventHandler.java
Executable file → Normal file
28
src/main/java/baritone/bot/GameEventHandler.java → src/main/java/baritone/bot/event/GameEventHandler.java
Executable file → Normal file
@ -15,13 +15,32 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.bot;
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.bot.event;
|
||||
|
||||
import baritone.bot.Baritone;
|
||||
import baritone.bot.InputOverrideHandler;
|
||||
import baritone.bot.behavior.Behavior;
|
||||
import baritone.bot.chunk.CachedWorld;
|
||||
import baritone.bot.chunk.CachedWorldProvider;
|
||||
import baritone.bot.chunk.ChunkPacker;
|
||||
import baritone.bot.event.IGameEventListener;
|
||||
import baritone.bot.event.listener.IGameEventListener;
|
||||
import baritone.bot.event.events.*;
|
||||
import baritone.bot.event.events.type.EventState;
|
||||
import baritone.bot.utils.Helper;
|
||||
@ -31,7 +50,6 @@ import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -41,8 +59,6 @@ import java.util.function.Consumer;
|
||||
*/
|
||||
public final class GameEventHandler implements IGameEventListener, Helper {
|
||||
|
||||
GameEventHandler() {}
|
||||
|
||||
@Override
|
||||
public final void onTick(TickEvent event) {
|
||||
dispatch(behavior -> behavior.onTick(event));
|
||||
@ -148,7 +164,7 @@ public final class GameEventHandler implements IGameEventListener, Helper {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.color(1.0F, 1.0F, 0.0F, 0.4F);
|
||||
GL11.glLineWidth(2.0F);
|
||||
GlStateManager.glLineWidth(2.0F);
|
||||
GlStateManager.disableTexture2D();
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
@ -15,7 +15,24 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.bot.event;
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.bot.event.listener;
|
||||
|
||||
import baritone.bot.event.events.*;
|
||||
|
19
src/main/java/baritone/bot/event/IGameEventListener.java → src/main/java/baritone/bot/event/listener/IGameEventListener.java
Executable file → Normal file
19
src/main/java/baritone/bot/event/IGameEventListener.java → src/main/java/baritone/bot/event/listener/IGameEventListener.java
Executable file → Normal file
@ -15,7 +15,24 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.bot.event;
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.bot.event.listener;
|
||||
|
||||
import baritone.bot.event.events.*;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
@ -19,6 +19,7 @@ package baritone.bot.pathing.movement;
|
||||
|
||||
import baritone.bot.utils.Helper;
|
||||
import baritone.bot.utils.ToolSet;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@ -28,6 +29,8 @@ import net.minecraft.item.ItemStack;
|
||||
*/
|
||||
public class CalculationContext implements Helper {
|
||||
|
||||
private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET);
|
||||
|
||||
private final ToolSet toolSet;
|
||||
private final boolean hasWaterBucket;
|
||||
|
||||
@ -37,7 +40,7 @@ public class CalculationContext implements Helper {
|
||||
|
||||
public CalculationContext(ToolSet toolSet) {
|
||||
this.toolSet = toolSet;
|
||||
this.hasWaterBucket = player().inventory.hasItemStack(new ItemStack(Items.WATER_BUCKET)); // TODO check if water bucket is on hotbar or main inventory
|
||||
this.hasWaterBucket = InventoryPlayer.isHotbar(player().inventory.getSlotFor(STACK_BUCKET_WATER));
|
||||
}
|
||||
|
||||
public ToolSet getToolSet() {
|
||||
|
@ -35,7 +35,7 @@ import java.util.Optional;
|
||||
public class MovementFall extends Movement {
|
||||
|
||||
private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET);
|
||||
private static final ItemStack STACK_BUCKET_AIR = new ItemStack(Items.BUCKET);
|
||||
private static final ItemStack STACK_BUCKET_EMPTY = new ItemStack(Items.BUCKET);
|
||||
|
||||
public MovementFall(BlockPos src, BlockPos dest) {
|
||||
super(src, dest, MovementFall.buildPositionsToBreak(src, dest), new BlockPos[]{dest.down()});
|
||||
@ -89,8 +89,8 @@ public class MovementFall extends Movement {
|
||||
}
|
||||
if (playerFeet.equals(dest) && (player().posY - playerFeet.getY() < 0.01
|
||||
|| BlockStateInterface.isWater(dest))) {
|
||||
if (BlockStateInterface.isWater(dest) && player().inventory.hasItemStack(STACK_BUCKET_AIR)) {
|
||||
player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_AIR);
|
||||
if (BlockStateInterface.isWater(dest) && player().inventory.hasItemStack(STACK_BUCKET_EMPTY)) {
|
||||
player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_EMPTY);
|
||||
if (player().motionY >= 0) {
|
||||
return state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true);
|
||||
} else {
|
||||
|
@ -29,7 +29,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
@ -52,7 +51,7 @@ public final class PathRenderer implements Helper {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F);
|
||||
GL11.glLineWidth(3.0F);
|
||||
GlStateManager.glLineWidth(3.0F);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
List<BlockPos> positions = path.positions();
|
||||
@ -99,7 +98,7 @@ public final class PathRenderer implements Helper {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.color(color.getColorComponents(null)[0], color.getColorComponents(null)[1], color.getColorComponents(null)[2], 0.4F);
|
||||
GL11.glLineWidth(5.0F);
|
||||
GlStateManager.glLineWidth(5.0F);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
float expand = 0.002F;
|
||||
|
Loading…
Reference in New Issue
Block a user