Fix water bucket falling, fixes #91
This commit is contained in:
parent
1801551d3b
commit
5ec99977fa
@ -18,26 +18,20 @@
|
||||
package baritone.pathing.movement.movements;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.behavior.impl.LookBehaviorUtils;
|
||||
import baritone.pathing.movement.CalculationContext;
|
||||
import baritone.pathing.movement.Movement;
|
||||
import baritone.pathing.movement.MovementHelper;
|
||||
import baritone.pathing.movement.MovementState;
|
||||
import baritone.pathing.movement.MovementState.MovementStatus;
|
||||
import baritone.pathing.movement.MovementState.MovementTarget;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.InputOverrideHandler;
|
||||
import baritone.utils.Rotation;
|
||||
import baritone.utils.Utils;
|
||||
import net.minecraft.block.Block;
|
||||
import baritone.utils.*;
|
||||
import net.minecraft.block.BlockFalling;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MovementFall extends Movement {
|
||||
|
||||
private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET);
|
||||
@ -96,20 +90,26 @@ public class MovementFall extends Movement {
|
||||
}
|
||||
|
||||
BlockPos playerFeet = playerFeet();
|
||||
Optional<Rotation> targetRotation = Optional.empty();
|
||||
Rotation targetRotation = null;
|
||||
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > Baritone.settings().maxFallHeightNoWater.get() && !playerFeet.equals(dest)) {
|
||||
if (!player().inventory.hasItemStack(STACK_BUCKET_WATER) || world().provider.isNether()) { // TODO check if water bucket is on hotbar or main inventory
|
||||
state.setStatus(MovementStatus.UNREACHABLE);
|
||||
return state;
|
||||
}
|
||||
|
||||
if (player().posY - dest.getY() < mc.playerController.getBlockReachDistance()) {
|
||||
player().inventory.currentItem = player().inventory.getSlotFor(STACK_BUCKET_WATER);
|
||||
targetRotation = LookBehaviorUtils.reachable((BlockStateInterface.get(dest).getCollisionBoundingBox(mc.world, dest) == Block.NULL_AABB) ? dest : dest.down());
|
||||
|
||||
targetRotation = new Rotation(player().rotationYaw, 90.0F);
|
||||
|
||||
RayTraceResult trace = RayTraceUtils.simulateRayTrace(player().rotationYaw, 90.0F);
|
||||
if (trace != null && trace.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetRotation.isPresent()) {
|
||||
state.setInput(InputOverrideHandler.Input.CLICK_RIGHT, true)
|
||||
.setTarget(new MovementTarget(targetRotation.get(), true));
|
||||
if (targetRotation != null) {
|
||||
state.setTarget(new MovementTarget(targetRotation, true));
|
||||
} else {
|
||||
state.setTarget(new MovementTarget(Utils.calcRotationFromVec3d(playerHead(), Utils.getBlockPosCenter(dest)), false));
|
||||
}
|
||||
|
47
src/main/java/baritone/utils/RayTraceUtils.java
Normal file
47
src/main/java/baritone/utils/RayTraceUtils.java
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.utils;
|
||||
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/25/2018
|
||||
*/
|
||||
public final class RayTraceUtils implements Helper {
|
||||
|
||||
private RayTraceUtils() {}
|
||||
|
||||
public static RayTraceResult simulateRayTrace(float yaw, float pitch) {
|
||||
RayTraceResult oldTrace = mc.objectMouseOver;
|
||||
float oldYaw = mc.player.rotationYaw;
|
||||
float oldPitch = mc.player.rotationPitch;
|
||||
|
||||
mc.player.rotationYaw = yaw;
|
||||
mc.player.rotationPitch = pitch;
|
||||
|
||||
mc.entityRenderer.getMouseOver(1.0F);
|
||||
RayTraceResult result = mc.objectMouseOver;
|
||||
mc.objectMouseOver = oldTrace;
|
||||
|
||||
mc.player.rotationYaw = oldYaw;
|
||||
mc.player.rotationPitch = oldPitch;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user