Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 1.20.5 into 1.21.1 #4534

Merged
merged 33 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a07d7d0
Sync mixin and asm versions between common and tweaker
ZacSharp Jul 21, 2024
f6045b7
Merge pull request #4438 from ZacSharp/pr/1.19.4/build/syncMixinAndAsm
leijurv Jul 28, 2024
330089f
Shorten / simplify some Litematica related things
ZacSharp Jul 27, 2024
b12c4e9
Merge loading steps
ZacSharp Jul 29, 2024
b87a1fa
Take data directly from Litematica
ZacSharp Jul 28, 2024
246a246
Less nested schematics
ZacSharp Jul 29, 2024
e71547b
Take blocks from the schematic world
ZacSharp Jul 29, 2024
1a0cca7
Use toString like for schematica
ZacSharp Jul 29, 2024
99f9dd1
Performance
ZacSharp Jul 29, 2024
7609f30
Keep subregions as separate boxes
ZacSharp Jul 30, 2024
b915151
We don't expect any exceptions here anymore
ZacSharp Jul 30, 2024
6b6931c
Remove unused stub
ZacSharp Jul 30, 2024
4203289
✨ Setting to rotate schematics
ZacSharp Jul 28, 2024
7e8c852
✨ Setting to mirror schematics
ZacSharp Jul 28, 2024
e682fc7
Fix selection box aabbs
ZacSharp Aug 9, 2024
ef72c56
Merge pull request #4453 from ZacSharp/pr/1.19.4/schematics/litematic…
leijurv Aug 22, 2024
800545f
Merge pull request #4465 from ZacSharp/pr/1.20.6/selection/fixSelecti…
leijurv Aug 22, 2024
d25d6c2
Merge pull request #4452 from ZacSharp/pr/1.19.4/builder/rotateAndMir…
leijurv Sep 16, 2024
a690e1e
prepend feet to the path if start is adjacent to feet
babbaj Oct 14, 2024
1e2ae34
crucial performance optimization
babbaj Oct 15, 2024
d644c5b
a bit more elegant
babbaj Oct 15, 2024
f22f4ae
Merge pull request #4519 from babbaj/edge-fix
leijurv Oct 15, 2024
ea1de44
Don't call `shape.bounds()` on empty shapes
ZacSharp Oct 20, 2024
c25b132
Handle positions going out of bounds between ticks
ZacSharp Oct 20, 2024
991d822
Make soul sand `canWalkOn` again
ZacSharp Oct 20, 2024
8e8cfdd
Merge pull request #4529 from ZacSharp/pr/1.19.4/builder/fixEmptyShap…
leijurv Oct 21, 2024
58fcf32
Merge pull request #4530 from ZacSharp/pr/1.19.4/builder/fixPositionO…
leijurv Oct 21, 2024
db16386
Merge pull request #4531 from ZacSharp/pr/1.19.4/pathing/canWalkOnSou…
leijurv Oct 21, 2024
f665784
fix loops in path (fixes #4528)
babbaj Oct 21, 2024
93dee4f
Merge pull request #4532 from babbaj/fix-loops
leijurv Oct 21, 2024
2869503
Merge branch '1.19.4' into 1.20.5
ZacSharp Oct 22, 2024
b550b92
Merge pull request #4527 from ZacSharp/1.20.5-update
leijurv Oct 22, 2024
52cfe5c
Merge branch '1.20.5' into 1.21.1
ZacSharp Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ allprojects {
}

dependencies {
compileOnly "org.spongepowered:mixin:0.8"
compileOnly "org.ow2.asm:asm:9.7"
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.17.1+build.32:v2"
//launchImplementation('dev.babbaj:nether-pathfinder:1.3.0')
compileOnly "org.spongepowered:mixin:${project.mixin_version}"
compileOnly "org.ow2.asm:asm:${project.asm_version}"

implementation "dev.babbaj:nether-pathfinder:${project.nether_pathfinder_version}"

implementation 'com.google.code.findbugs:jsr305:3.0.2'
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ neoforge_version=20-beta
fabric_version=0.15.11

nether_pathfinder_version=1.4.1

// These dependencies are used for common and tweaker
// while mod loaders usually ship their own version
mixin_version=0.8.5
asm_version=9.7
25 changes: 25 additions & 0 deletions src/api/java/baritone/api/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -1089,6 +1092,28 @@ public final class Settings {
*/
public final Setting<Boolean> schematicOrientationZ = new Setting<>(false);

/**
* Rotates the schematic before building it.
* Possible values are
* <ul>
* <li> NONE - No rotation </li>
* <li> CLOCKWISE_90 - Rotate 90° clockwise </li>
* <li> CLOCKWISE_180 - Rotate 180° clockwise </li>
* <li> COUNTERCLOCKWISE_90 - Rotate 270° clockwise </li>
* </ul>
*/
public final Setting<Rotation> buildSchematicRotation = new Setting<>(Rotation.NONE);

/**
* Mirrors the schematic before building it.
* Possible values are
* <ul>
* <li> FRONT_BACK - mirror the schematic along its local x axis </li>
* <li> LEFT_RIGHT - mirror the schematic along its local z axis </li>
* </ul>
*/
public final Setting<Mirror> buildSchematicMirror = new Setting<>(Mirror.NONE);

/**
* The fallback used by the build command when no extension is specified. This may be useful if schematics of a
* particular format are used often, and the user does not wish to have to specify the extension with every usage.
Expand Down
114 changes: 114 additions & 0 deletions src/api/java/baritone/api/schematic/MirroredSchematic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* 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.api.schematic;

import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Mirror;

import java.util.List;
import java.util.stream.Collectors;

public class MirroredSchematic implements ISchematic {

private final ISchematic schematic;
private final Mirror mirror;

public MirroredSchematic(ISchematic schematic, Mirror mirror) {
this.schematic = schematic;
this.mirror = mirror;
}

@Override
public boolean inSchematic(int x, int y, int z, BlockState currentState) {
return schematic.inSchematic(
mirrorX(x, widthX(), mirror),
y,
mirrorZ(z, lengthZ(), mirror),
mirror(currentState, mirror)
);
}

@Override
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
return mirror(schematic.desiredState(
mirrorX(x, widthX(), mirror),
y,
mirrorZ(z, lengthZ(), mirror),
mirror(current, mirror),
mirror(approxPlaceable, mirror)
), mirror);
}

@Override
public void reset() {
schematic.reset();
}

@Override
public int widthX() {
return schematic.widthX();
}

@Override
public int heightY() {
return schematic.heightY();
}

@Override
public int lengthZ() {
return schematic.lengthZ();
}

private static int mirrorX(int x, int sizeX, Mirror mirror) {
switch (mirror) {
case NONE:
case LEFT_RIGHT:
return x;
case FRONT_BACK:
return sizeX - x - 1;
}
throw new IllegalArgumentException("Unknown mirror");
}

private static int mirrorZ(int z, int sizeZ, Mirror mirror) {
switch (mirror) {
case NONE:
case FRONT_BACK:
return z;
case LEFT_RIGHT:
return sizeZ - z - 1;
}
throw new IllegalArgumentException("Unknown mirror");
}

private static BlockState mirror(BlockState state, Mirror mirror) {
if (state == null) {
return null;
}
return state.mirror(mirror);
}

private static List<BlockState> mirror(List<BlockState> states, Mirror mirror) {
if (states == null) {
return null;
}
return states.stream()
.map(s -> mirror(s, mirror))
.collect(Collectors.toList());
}
}
136 changes: 136 additions & 0 deletions src/api/java/baritone/api/schematic/RotatedSchematic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* 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.api.schematic;

import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Rotation;

import java.util.List;
import java.util.stream.Collectors;

public class RotatedSchematic implements ISchematic {

private final ISchematic schematic;
private final Rotation rotation;
private final Rotation inverseRotation;

public RotatedSchematic(ISchematic schematic, Rotation rotation) {
this.schematic = schematic;
this.rotation = rotation;
// I don't think a 14 line switch would improve readability
this.inverseRotation = rotation.getRotated(rotation).getRotated(rotation);
}

@Override
public boolean inSchematic(int x, int y, int z, BlockState currentState) {
return schematic.inSchematic(
rotateX(x, z, widthX(), lengthZ(), inverseRotation),
y,
rotateZ(x, z, widthX(), lengthZ(), inverseRotation),
rotate(currentState, inverseRotation)
);
}

@Override
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
return rotate(schematic.desiredState(
rotateX(x, z, widthX(), lengthZ(), inverseRotation),
y,
rotateZ(x, z, widthX(), lengthZ(), inverseRotation),
rotate(current, inverseRotation),
rotate(approxPlaceable, inverseRotation)
), rotation);
}

@Override
public void reset() {
schematic.reset();
}

@Override
public int widthX() {
return flipsCoordinates(rotation) ? schematic.lengthZ() : schematic.widthX();
}

@Override
public int heightY() {
return schematic.heightY();
}

@Override
public int lengthZ() {
return flipsCoordinates(rotation) ? schematic.widthX() : schematic.lengthZ();
}

/**
* Wether {@code rotation} swaps the x and z components
*/
private static boolean flipsCoordinates(Rotation rotation) {
return rotation == Rotation.CLOCKWISE_90 || rotation == Rotation.COUNTERCLOCKWISE_90;
}

/**
* The x component of x,y after applying the rotation
*/
private static int rotateX(int x, int z, int sizeX, int sizeZ, Rotation rotation) {
switch (rotation) {
case NONE:
return x;
case CLOCKWISE_90:
return sizeZ - z - 1;
case CLOCKWISE_180:
return sizeX - x - 1;
case COUNTERCLOCKWISE_90:
return z;
}
throw new IllegalArgumentException("Unknown rotation");
}

/**
* The z component of x,y after applying the rotation
*/
private static int rotateZ(int x, int z, int sizeX, int sizeZ, Rotation rotation) {
switch (rotation) {
case NONE:
return z;
case CLOCKWISE_90:
return x;
case CLOCKWISE_180:
return sizeZ - z - 1;
case COUNTERCLOCKWISE_90:
return sizeX - x - 1;
}
throw new IllegalArgumentException("Unknown rotation");
}

private static BlockState rotate(BlockState state, Rotation rotation) {
if (state == null) {
return null;
}
return state.rotate(rotation);
}

private static List<BlockState> rotate(List<BlockState> states, Rotation rotation) {
if (states == null) {
return null;
}
return states.stream()
.map(s -> rotate(s, rotation))
.collect(Collectors.toList());
}
}
6 changes: 5 additions & 1 deletion src/api/java/baritone/api/utils/SettingsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;

import java.awt.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
Expand Down Expand Up @@ -220,7 +223,8 @@ private enum Parser implements ISettingParser {
FLOAT(Float.class, Float::parseFloat),
LONG(Long.class, Long::parseLong),
STRING(String.class, String::new),
DIRECTION(Direction.class, Direction::byName),
MIRROR(Mirror.class, Mirror::valueOf, Mirror::name),
ROTATION(Rotation.class, Rotation::valueOf, Rotation::name),
COLOR(
Color.class,
str -> new Color(Integer.parseInt(str.split(",")[0]), Integer.parseInt(str.split(",")[1]), Integer.parseInt(str.split(",")[2])),
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/baritone/behavior/PathingBehavior.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public boolean secretInternalSetGoalAndPath(PathingCommand command) {
if (goal == null) {
return false;
}
if (goal.isInGoal(ctx.playerFeet()) || goal.isInGoal(expectedSegmentStart)) {
if (goal.isInGoal(ctx.playerFeet())) {
return false;
}
synchronized (pathPlanLock) {
Expand Down Expand Up @@ -553,7 +553,7 @@ private void findPathInNewThread(final BlockPos start, final boolean talkAboutIt
});
}

private static AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal, IPath previous, CalculationContext context) {
private AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal, IPath previous, CalculationContext context) {
Goal transformed = goal;
if (Baritone.settings().simplifyUnloadedYCoord.value && goal instanceof IGoalRenderPos) {
BlockPos pos = ((IGoalRenderPos) goal).getGoalPos();
Expand All @@ -562,7 +562,14 @@ private static AbstractNodeCostSearch createPathfinder(BlockPos start, Goal goal
}
}
Favoring favoring = new Favoring(context.getBaritone().getPlayerContext(), previous, context);
return new AStarPathFinder(start.getX(), start.getY(), start.getZ(), transformed, favoring, context);
BetterBlockPos feet = ctx.playerFeet();
var realStart = new BetterBlockPos(start);
var sub = feet.subtract(realStart);
if (feet.getY() == realStart.getY() && Math.abs(sub.getX()) <= 1 && Math.abs(sub.getZ()) <= 1) {
realStart = feet;
}
return new AStarPathFinder(realStart, start.getX(), start.getY(), start.getZ(), transformed, favoring, context);

}

@Override
Expand Down
15 changes: 3 additions & 12 deletions src/main/java/baritone/command/defaults/LitematicaCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,9 @@ public LitematicaCommand(IBaritone baritone) {

@Override
public void execute(String label, IArgConsumer args) throws CommandException {
int schematic = 0;
if (args.hasAny()) {
args.requireMax(1);
if (args.is(Integer.class)) {
schematic = args.getAs(Integer.class) - 1;
}
}
try {
baritone.getBuilderProcess().buildOpenLitematic(schematic);
} catch (IndexOutOfBoundsException e) {
logDirect("Pleas provide a valid index.");
}
args.requireMax(1);
int schematic = args.hasAny() ? args.getAs(Integer.class) - 1 : 0;
baritone.getBuilderProcess().buildOpenLitematic(schematic);
}

@Override
Expand Down
Loading