Skip to content

Commit 8a7dcae

Browse files
committed
Fix incorrect building rotation
1 parent f9cb8c9 commit 8a7dcae

2 files changed

Lines changed: 29 additions & 15 deletions

File tree

src/main/java/com/minecolonies/api/util/ColonyUtils.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import net.minecraft.world.level.Level;
1111
import net.minecraft.world.level.block.Mirror;
1212
import net.minecraft.world.level.chunk.LevelChunk;
13+
import net.minecraft.world.phys.AABB;
14+
import org.jetbrains.annotations.NotNull;
1315
import org.jetbrains.annotations.Nullable;
1416

1517
import java.util.*;
@@ -101,7 +103,7 @@ public static CompletableFuture<Blueprint> queueBlueprintLoad(
101103
}
102104

103105
/**
104-
* Calculated the corner of a building.
106+
* Calculated the corner of a building. Also rotates the blueprint accordingly.
105107
*
106108
* @param pos the central position.
107109
* @param world the world.
@@ -131,6 +133,19 @@ public static Tuple<BlockPos, BlockPos> calculateCorners(
131133
return new Tuple<>(pos1, pos2);
132134
}
133135

136+
/**
137+
* Reports the block corners from a bounding box.
138+
*
139+
* @param box the bounding box.
140+
* @return the corners.
141+
*/
142+
public static Tuple<BlockPos, BlockPos> calculateCorners(@NotNull final AABB box)
143+
{
144+
final BlockPos min = BlockPos.containing(box.minX, box.minY, box.minZ);
145+
final BlockPos max = BlockPos.containing(box.maxX, box.maxY, box.maxZ);
146+
return new Tuple<>(min, max);
147+
}
148+
134149
/**
135150
* Get the owning colony from a chunk.
136151
* @param chunk the chunk to check.

src/main/java/com/minecolonies/core/entity/ai/workers/util/ConstructionTapeHelper.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
import net.minecraft.world.level.block.state.BlockState;
2020
import net.minecraft.world.level.block.state.properties.BooleanProperty;
2121
import net.minecraft.world.level.block.state.properties.DirectionProperty;
22+
import net.minecraft.world.phys.AABB;
2223
import org.jetbrains.annotations.NotNull;
2324
import org.jetbrains.annotations.Nullable;
2425

26+
import static com.minecolonies.api.util.constant.Constants.EMPTY_AABB;
27+
2528
/**
2629
* Helper class to place and remove constructionTapes from the buildings.
2730
*/
@@ -43,13 +46,11 @@ private ConstructionTapeHelper() {}
4346
*/
4447
public static void placeConstructionTape(@NotNull final IWorkOrder workOrder, @NotNull final Level world, final IColony colony)
4548
{
46-
workOrder.loadBlueprint(world, (blueprint -> {
47-
if (blueprint != null)
48-
{
49-
final Tuple<BlockPos, BlockPos> corners = ColonyUtils.calculateCorners(workOrder.getLocation(), world, blueprint, workOrder.getRotation(), workOrder.isMirrored());
50-
placeConstructionTape(corners, colony);
51-
}
52-
}));
49+
final AABB box = workOrder.getBoundingBox();
50+
if (box != null && box != EMPTY_AABB)
51+
{
52+
placeConstructionTape(ColonyUtils.calculateCorners(box), colony);
53+
}
5354
}
5455

5556
/**
@@ -175,13 +176,11 @@ public static BlockPos firstValidPosition(@NotNull final BlockPos target, @NotNu
175176
*/
176177
public static void removeConstructionTape(@NotNull final IWorkOrder workOrder, @NotNull final Level world)
177178
{
178-
workOrder.loadBlueprint(world, (blueprint -> {
179-
if (blueprint != null)
180-
{
181-
final Tuple<BlockPos, BlockPos> corners = ColonyUtils.calculateCorners(workOrder.getLocation(), world, blueprint, workOrder.getRotation(), workOrder.isMirrored());
182-
removeConstructionTape(corners, world);
183-
}
184-
}));
179+
final AABB box = workOrder.getBoundingBox();
180+
if (box != null && box != EMPTY_AABB)
181+
{
182+
removeConstructionTape(ColonyUtils.calculateCorners(box), world);
183+
}
185184
}
186185

187186
/**

0 commit comments

Comments
 (0)