Skip to content

Commit

Permalink
Fix citizens not properly jumping (#10359)
Browse files Browse the repository at this point in the history
Fix citizens not properly jumping
  • Loading branch information
someaddons authored and Raycoms committed Oct 25, 2024
1 parent 07cafcb commit 33d226b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/minecolonies/api/util/ShapeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static double max(final VoxelShape shape, final Direction.Axis axis)
return 1.0;
}

// Note: in vanilla this is -infinity
if (shape == Shapes.empty())
{
return 0;
Expand All @@ -45,6 +46,7 @@ public static double min(final VoxelShape shape, final Direction.Axis axis)
return 0.0;
}

// Note: in vanilla this is +infinity
if (shape == Shapes.empty())
{
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ else if (this.path != null && !this.path.isDone())
if (!this.isDone())
{
Vec3 vector3d2 = path.getNextEntityPos(mob);
tempPos.set(Mth.floor(vector3d2.x), Mth.floor(vector3d2.y) - 1, Mth.floor(vector3d2.z));
tempPos.set(Mth.floor(vector3d2.x), Mth.floor(vector3d2.y), Mth.floor(vector3d2.z));
if (ChunkPos.asLong(tempPos) == mob.chunkPosition().toLong() || WorldUtil.isEntityBlockLoaded(level, tempPos))
{
mob.getMoveControl()
Expand Down Expand Up @@ -401,21 +401,32 @@ else if (this.path != null && !this.path.isDone())
* @param y
* @return the next y level to go to.
*/
public static double getSmartGroundY(final BlockGetter world, final BlockPos pos, final double orgY)
public static double getSmartGroundY(final BlockGetter world, final BlockPos.MutableBlockPos pos, final double orgY)
{
final BlockState state = world.getBlockState(pos);
if (state.isAir())
BlockState state = world.getBlockState(pos);

if (!state.isAir())
{
return orgY;
final VoxelShape voxelshape = state.getCollisionShape(world, pos);
if (!ShapeUtil.isEmpty(voxelshape))
{
return pos.getY() + ShapeUtil.max(voxelshape, Direction.Axis.Y);
}
}

final VoxelShape voxelshape = state.getCollisionShape(world, pos);
final double maxY = ShapeUtil.max(voxelshape, Direction.Axis.Y);
if (maxY < 1.0)
pos.set(pos.getX(), pos.getY() - 1, pos.getZ());

state = world.getBlockState(pos);
if (!state.isAir())
{
return pos.getY();
final VoxelShape voxelshape = state.getCollisionShape(world, pos);
if (!ShapeUtil.isEmpty(voxelshape))
{
return pos.getY() + ShapeUtil.max(voxelshape, Direction.Axis.Y);
}
}
return pos.getY() + maxY;

return orgY;
}

@Nullable
Expand Down

0 comments on commit 33d226b

Please sign in to comment.