From 4a9275fa14342cb1fcc6099ffdf46cf6e3ff0417 Mon Sep 17 00:00:00 2001 From: Raycoms Date: Thu, 12 Sep 2024 21:12:12 +0200 Subject: [PATCH] fix auto upgrade to level 5 when resolving rotation --- .../TileEntityColonyBuilding.java | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/minecolonies/core/tileentities/TileEntityColonyBuilding.java b/src/main/java/com/minecolonies/core/tileentities/TileEntityColonyBuilding.java index f7058d1d2f2..5826d7dc72d 100755 --- a/src/main/java/com/minecolonies/core/tileentities/TileEntityColonyBuilding.java +++ b/src/main/java/com/minecolonies/core/tileentities/TileEntityColonyBuilding.java @@ -514,7 +514,7 @@ public RotationMirror getRotationMirror() { if (rotationMirror == null) { - processBlueprint(StructurePacks.getBlueprint(this.packMeta, this.path.replace("0.blueprint", "1.blueprint"), level.registryAccess())); + calcRotation(StructurePacks.getBlueprint(this.packMeta, this.path.replace("0.blueprint", "1.blueprint"), level.registryAccess())); } return rotationMirror; } @@ -681,42 +681,46 @@ private void processBlueprint(final Blueprint blueprint) return; } - final BlockState structureState = blueprint.getBlockState(blueprint.getPrimaryBlockOffset()); - if (structureState != null) + calcRotation(blueprint); + + final BlockInfo info = blueprint.getBlockInfoAsMap().getOrDefault(blueprint.getPrimaryBlockOffset(), null); + + if (info.getTileEntityData() != null) { - if (!(structureState.getBlock() instanceof AbstractBlockHut) || !(level.getBlockState(this.getPosition()).getBlock() instanceof AbstractBlockHut)) - { - Log.getLogger().error(String.format("Schematic %s doesn't have a correct Primary Offset", blueprint.getName())); - return; - } - final int structureRotation = structureState.getValue(AbstractBlockHut.FACING).get2DDataValue(); - final int worldRotation = level.getBlockState(this.getPosition()).getValue(AbstractBlockHut.FACING).get2DDataValue(); + final CompoundTag teCompound = info.getTileEntityData().copy(); + final CompoundTag tagData = teCompound.getCompound(TAG_BLUEPRINTDATA); - final int rotation; - if (structureRotation <= worldRotation) - { - rotation = worldRotation - structureRotation; - } - else - { - rotation = 4 + worldRotation - structureRotation; - } + tagData.putString(TAG_PACK, blueprint.getPackName()); + final String location = StructurePacks.getStructurePack(blueprint.getPackName()).getSubPath(blueprint.getFilePath().resolve(blueprint.getFileName())); + tagData.putString(TAG_NAME, location); + this.readSchematicDataFromNBT(teCompound); + } + } - rotationMirror = RotationMirror.of(Rotation.values()[rotation], rotationMirror == null ? Mirror.NONE : rotationMirror.mirror()); - blueprint.setRotationMirror(rotationMirror, level); - final BlockInfo info = blueprint.getBlockInfoAsMap().getOrDefault(blueprint.getPrimaryBlockOffset(), null); + private void calcRotation(final Blueprint blueprint) + { + final BlockState structureState = blueprint.getBlockState(blueprint.getPrimaryBlockOffset()); + if (structureState == null || !(structureState.getBlock() instanceof AbstractBlockHut) || !(level.getBlockState(this.getPosition()).getBlock() instanceof AbstractBlockHut)) + { + rotationMirror = RotationMirror.NONE; + return; + } - if (info.getTileEntityData() != null) - { - final CompoundTag teCompound = info.getTileEntityData().copy(); - final CompoundTag tagData = teCompound.getCompound(TAG_BLUEPRINTDATA); + final int structureRotation = structureState.getValue(AbstractBlockHut.FACING).get2DDataValue(); + final int worldRotation = level.getBlockState(this.getPosition()).getValue(AbstractBlockHut.FACING).get2DDataValue(); - tagData.putString(TAG_PACK, blueprint.getPackName()); - final String location = StructurePacks.getStructurePack(blueprint.getPackName()).getSubPath(blueprint.getFilePath().resolve(blueprint.getFileName())); - tagData.putString(TAG_NAME, location); - this.readSchematicDataFromNBT(teCompound); - } + final int rotation; + if (structureRotation <= worldRotation) + { + rotation = worldRotation - structureRotation; + } + else + { + rotation = 4 + worldRotation - structureRotation; } + + rotationMirror = RotationMirror.of(Rotation.values()[rotation], rotationMirror == null ? Mirror.NONE : rotationMirror.mirror()); + blueprint.setRotationMirror(rotationMirror, level); } /**