use of net.minecraft.block.LadderBlock in project minecolonies by Minecolonies.
the class MinecoloniesAdvancedPathNavigate method handlePathPointOnLadder.
private boolean handlePathPointOnLadder(final PathPointExtended pEx) {
Vector3d vec3 = this.getPath().getNextEntityPos(this.ourEntity);
final BlockPos entityPos = new BlockPos(this.ourEntity.position());
if (vec3.distanceToSqr(ourEntity.getX(), vec3.y, ourEntity.getZ()) < 0.6 && Math.abs(vec3.y - entityPos.getY()) <= 2.0) {
// This way he is less nervous and gets up the ladder
double newSpeed = 0.3;
switch(pEx.getLadderFacing()) {
// Any of these values is climbing, so adjust our direction of travel towards the ladder
case NORTH:
vec3 = vec3.add(0, 0, 0.4);
break;
case SOUTH:
vec3 = vec3.add(0, 0, -0.4);
break;
case WEST:
vec3 = vec3.add(0.4, 0, 0);
break;
case EAST:
vec3 = vec3.add(-0.4, 0, 0);
break;
case UP:
vec3 = vec3.add(0, 1, 0);
break;
// Any other value is going down, so lets not move at all
default:
newSpeed = 0;
mob.setShiftKeyDown(true);
isSneaking = true;
this.ourEntity.getMoveControl().setWantedPosition(vec3.x, vec3.y, vec3.z, 0.2);
break;
}
if (newSpeed > 0) {
if (!(level.getBlockState(ourEntity.blockPosition()).getBlock() instanceof LadderBlock)) {
this.ourEntity.setDeltaMovement(this.ourEntity.getDeltaMovement().add(0, 0.1D, 0));
}
this.ourEntity.getMoveControl().setWantedPosition(vec3.x, vec3.y, vec3.z, newSpeed);
} else {
if (level.getBlockState(entityPos.below()).isLadder(level, entityPos.below(), ourEntity)) {
this.ourEntity.setYya(-0.5f);
} else {
return false;
}
return true;
}
}
return false;
}
use of net.minecraft.block.LadderBlock in project BleachHack by BleachDrinker420.
the class AutoParkour method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
if (smartPos != null) {
if (mc.player.getY() - 0.5 < smartPos.getY() && mc.player.getVelocity().y < 0) {
smartPos = null;
}
}
if (!mc.player.isSneaking() && mc.player.isOnGround()) {
smartPos = null;
Box box = mc.player.getBoundingBox().offset(0, -0.51, 0);
Stream<VoxelShape> blockCollisions = mc.world.getBlockCollisions(mc.player, box);
if (blockCollisions.findAny().isEmpty()) {
if (getSetting(0).asToggle().getState() && !mc.player.isSprinting()) {
mc.player.setSprinting(true);
mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.START_SPRINTING));
}
if (getSetting(1).asToggle().getState()) {
Vec3d lookVec = mc.player.getPos().add(new Vec3d(0, 0, 3.5).rotateY(-(float) Math.toRadians(mc.player.getYaw())));
BlockPos nearestPos = BlockPos.streamOutwards(mc.player.getBlockPos().down(), 4, 1, 4).map(BlockPos::toImmutable).filter(pos -> (mc.world.isTopSolid(pos, mc.player) && mc.world.getBlockCollisions(mc.player, new Box(pos.up(), pos.add(1, 3, 1))).findAny().isEmpty()) || mc.world.getBlockState(pos).getBlock() instanceof LadderBlock || mc.world.getBlockState(pos.up()).getBlock() instanceof LadderBlock).filter(pos -> mc.player.getPos().distanceTo(Vec3d.of(pos).add(0.5, 1, 0.5)) >= 1).filter(pos -> mc.player.getPos().distanceTo(Vec3d.of(pos).add(0.5, 1, 0.5)) <= 4.5).sorted(Comparator.comparing(pos -> pos.getSquaredDistance(lookVec, false))).findFirst().orElse(null);
if (nearestPos != null) {
smartPos = nearestPos;
}
}
mc.player.jump();
}
}
}
use of net.minecraft.block.LadderBlock in project minecolonies by ldtteam.
the class MinecoloniesAdvancedPathNavigate method handlePathPointOnLadder.
private boolean handlePathPointOnLadder(final PathPointExtended pEx) {
Vector3d vec3 = this.getPath().getNextEntityPos(this.ourEntity);
final BlockPos entityPos = new BlockPos(this.ourEntity.position());
if (vec3.distanceToSqr(ourEntity.getX(), vec3.y, ourEntity.getZ()) < 0.6 && Math.abs(vec3.y - entityPos.getY()) <= 2.0) {
// This way he is less nervous and gets up the ladder
double newSpeed = 0.3;
switch(pEx.getLadderFacing()) {
// Any of these values is climbing, so adjust our direction of travel towards the ladder
case NORTH:
vec3 = vec3.add(0, 0, 0.4);
break;
case SOUTH:
vec3 = vec3.add(0, 0, -0.4);
break;
case WEST:
vec3 = vec3.add(0.4, 0, 0);
break;
case EAST:
vec3 = vec3.add(-0.4, 0, 0);
break;
case UP:
vec3 = vec3.add(0, 1, 0);
break;
// Any other value is going down, so lets not move at all
default:
newSpeed = 0;
mob.setShiftKeyDown(true);
isSneaking = true;
this.ourEntity.getMoveControl().setWantedPosition(vec3.x, vec3.y, vec3.z, 0.2);
break;
}
if (newSpeed > 0) {
if (!(level.getBlockState(ourEntity.blockPosition()).getBlock() instanceof LadderBlock)) {
this.ourEntity.setDeltaMovement(this.ourEntity.getDeltaMovement().add(0, 0.1D, 0));
}
this.ourEntity.getMoveControl().setWantedPosition(vec3.x, vec3.y, vec3.z, newSpeed);
} else {
if (level.getBlockState(entityPos.below()).isLadder(level, entityPos.below(), ourEntity)) {
this.ourEntity.setYya(-0.5f);
} else {
return false;
}
return true;
}
}
return false;
}
Aggregations