Fix some things mentioned by @Leijurv

This commit is contained in:
Brady 2018-11-13 16:33:45 -06:00
parent 17161fd576
commit 5e2f40a322
No known key found for this signature in database
GPG Key ID: 73A788379A197567
12 changed files with 22 additions and 59 deletions

View File

@ -18,6 +18,7 @@
package baritone.api.utils; package baritone.api.utils;
import baritone.api.cache.IWorldData; import baritone.api.cache.IWorldData;
import net.minecraft.block.BlockSlab;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@ -37,7 +38,14 @@ public interface IPlayerContext {
IWorldData worldData(); IWorldData worldData();
BetterBlockPos playerFeet(); default BetterBlockPos playerFeet() {
// TODO find a better way to deal with soul sand!!!!!
BetterBlockPos feet = new BetterBlockPos(player().posX, player().posY + 0.1251, player().posZ);
if (world().getBlockState(feet).getBlock() instanceof BlockSlab) {
return feet.up();
}
return feet;
}
default Vec3d playerFeetAsVec() { default Vec3d playerFeetAsVec() {
return new Vec3d(player().posX, player().posY, player().posZ); return new Vec3d(player().posX, player().posY, player().posZ);

View File

@ -23,9 +23,8 @@ import baritone.api.behavior.ILookBehavior;
import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.RotationMoveEvent; import baritone.api.event.events.RotationMoveEvent;
import baritone.api.utils.Rotation; import baritone.api.utils.Rotation;
import baritone.utils.Helper;
public final class LookBehavior extends Behavior implements ILookBehavior, Helper { public final class LookBehavior extends Behavior implements ILookBehavior {
/** /**
* Target's values are as follows: * Target's values are as follows:

View File

@ -27,7 +27,6 @@ import baritone.api.event.events.PlayerUpdateEvent;
import baritone.api.event.events.type.EventState; import baritone.api.event.events.type.EventState;
import baritone.cache.Waypoint; import baritone.cache.Waypoint;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.Helper;
import net.minecraft.block.BlockBed; import net.minecraft.block.BlockBed;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
@ -45,7 +44,7 @@ import java.util.*;
* @author Brady * @author Brady
* @since 8/6/2018 9:47 PM * @since 8/6/2018 9:47 PM
*/ */
public final class MemoryBehavior extends Behavior implements IMemoryBehavior, Helper { public final class MemoryBehavior extends Behavior implements IMemoryBehavior {
private final Map<IWorldData, WorldDataContainer> worldDataContainers = new HashMap<>(); private final Map<IWorldData, WorldDataContainer> worldDataContainers = new HashMap<>();

View File

@ -17,7 +17,6 @@
package baritone.cache; package baritone.cache;
import baritone.utils.Helper;
import baritone.utils.pathing.PathingBlockType; import baritone.utils.pathing.PathingBlockType;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -30,7 +29,7 @@ import java.util.*;
* @author Brady * @author Brady
* @since 8/3/2018 1:04 AM * @since 8/3/2018 1:04 AM
*/ */
public final class CachedChunk implements Helper { public final class CachedChunk {
public static final Set<Block> BLOCKS_TO_KEEP_TRACK_OF; public static final Set<Block> BLOCKS_TO_KEEP_TRACK_OF;

View File

@ -18,7 +18,6 @@
package baritone.cache; package baritone.cache;
import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementHelper;
import baritone.utils.Helper;
import baritone.utils.pathing.PathingBlockType; import baritone.utils.pathing.PathingBlockType;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockDoublePlant; import net.minecraft.block.BlockDoublePlant;
@ -38,7 +37,7 @@ import java.util.*;
* @author Brady * @author Brady
* @since 8/3/2018 1:09 AM * @since 8/3/2018 1:09 AM
*/ */
public final class ChunkPacker implements Helper { public final class ChunkPacker {
private ChunkPacker() {} private ChunkPacker() {}

View File

@ -19,7 +19,6 @@ package baritone.cache;
import baritone.api.cache.IWorldScanner; import baritone.api.cache.IWorldScanner;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
import baritone.utils.Helper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.multiplayer.ChunkProviderClient; import net.minecraft.client.multiplayer.ChunkProviderClient;
@ -31,7 +30,7 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
public enum WorldScanner implements IWorldScanner, Helper { public enum WorldScanner implements IWorldScanner {
INSTANCE; INSTANCE;

View File

@ -88,7 +88,7 @@ public class CalculationContext {
} }
public final IBaritone getBaritone() { public final IBaritone getBaritone() {
return this.baritone; return baritone;
} }
public IBlockState get(int x, int y, int z) { public IBlockState get(int x, int y, int z) {

View File

@ -23,7 +23,6 @@ import baritone.api.pathing.movement.MovementStatus;
import baritone.api.utils.*; import baritone.api.utils.*;
import baritone.api.utils.input.Input; import baritone.api.utils.input.Input;
import baritone.utils.BlockStateInterface; import baritone.utils.BlockStateInterface;
import baritone.utils.Helper;
import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockLiquid;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -34,7 +33,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
public abstract class Movement implements IMovement, Helper, MovementHelper { public abstract class Movement implements IMovement, MovementHelper {
protected static final EnumFacing[] HORIZONTALS = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST}; protected static final EnumFacing[] HORIZONTALS = {EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST};

View File

@ -45,7 +45,7 @@ import java.util.Objects;
public class MovementParkour extends Movement { public class MovementParkour extends Movement {
private static final EnumFacing[] HORIZONTAL_AND_DOWN = { EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN }; private static final EnumFacing[] HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP = { EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.EAST, EnumFacing.WEST, EnumFacing.DOWN };
private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{}; private static final BetterBlockPos[] EMPTY = new BetterBlockPos[]{};
private final EnumFacing direction; private final EnumFacing direction;
@ -139,8 +139,8 @@ public class MovementParkour extends Movement {
return; return;
} }
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
int againstX = destX + HORIZONTAL_AND_DOWN[i].getXOffset(); int againstX = destX + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP [i].getXOffset();
int againstZ = destZ + HORIZONTAL_AND_DOWN[i].getZOffset(); int againstZ = destZ + HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP [i].getZOffset();
if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast if (againstX == x + xDiff * 3 && againstZ == z + zDiff * 3) { // we can't turn around that fast
continue; continue;
} }
@ -216,7 +216,7 @@ public class MovementParkour extends Movement {
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround) { if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround) {
BlockPos positionToPlace = dest.down(); BlockPos positionToPlace = dest.down();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
BlockPos against1 = positionToPlace.offset(HORIZONTAL_AND_DOWN[i]); BlockPos against1 = positionToPlace.offset(HORIZONTALS_BUT_ALSO_DOWN____SO_EVERY_DIRECTION_EXCEPT_UP [i]);
if (against1.up().equals(src.offset(direction, 3))) { // we can't turn around that fast if (against1.up().equals(src.offset(direction, 3))) { // we can't turn around that fast
continue; continue;
} }

View File

@ -35,7 +35,7 @@ import net.minecraft.world.chunk.Chunk;
* *
* @author leijurv * @author leijurv
*/ */
public class BlockStateInterface implements Helper { public class BlockStateInterface {
private final World world; private final World world;
private final WorldData worldData; private final WorldData worldData;

View File

@ -1,39 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.utils.player;
import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.IPlayerContext;
import net.minecraft.block.BlockSlab;
/**
* @author Brady
* @since 11/12/2018
*/
public abstract class AbstractPlayerContext implements IPlayerContext {
@Override
public BetterBlockPos playerFeet() {
// TODO find a better way to deal with soul sand!!!!!
BetterBlockPos feet = new BetterBlockPos(player().posX, player().posY + 0.1251, player().posZ);
if (world().getBlockState(feet).getBlock() instanceof BlockSlab) {
return feet.up();
}
return feet;
}
}

View File

@ -31,7 +31,7 @@ import net.minecraft.world.World;
* @author Brady * @author Brady
* @since 11/12/2018 * @since 11/12/2018
*/ */
public final class LocalPlayerContext extends AbstractPlayerContext { public final class LocalPlayerContext implements IPlayerContext {
private static final Minecraft mc = Minecraft.getMinecraft(); private static final Minecraft mc = Minecraft.getMinecraft();