Skip to content

Commit 501faa4

Browse files
authored
Fix/building rotation (#10809)
* Revert level 0 tag data, turns out this introduces more weirdness than it solves * Fix incorrect building rotation
1 parent 6ce8490 commit 501faa4

3 files changed

Lines changed: 29 additions & 17 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
/**

src/main/java/com/minecolonies/core/placementhandlers/main/SurvivalHandler.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.ldtteam.structurize.blocks.interfaces.ILeveledBlueprintAnchorBlock;
44
import com.ldtteam.structurize.blueprints.v1.Blueprint;
5-
import com.ldtteam.structurize.placement.handlers.placement.PlacementHandlers;
65
import com.ldtteam.structurize.storage.ISurvivalBlueprintHandler;
76
import com.ldtteam.structurize.storage.StructurePacks;
87
import com.ldtteam.structurize.util.PlacementSettings;
@@ -167,7 +166,6 @@ public void handle(
167166

168167
world.destroyBlock(blockPos, true);
169168
world.setBlockAndUpdate(blockPos, anchor);
170-
PlacementHandlers.handleTileEntityPlacement(blueprint.getTileEntityData(blockPos, blueprint.getPrimaryBlockOffset()), world, blockPos);
171169
((AbstractBlockHut<?>) anchor.getBlock()).onBlockPlacedByBuildTool(world,
172170
blockPos,
173171
anchor,

0 commit comments

Comments
 (0)