From e83b9b756311a12ac8e48b94a4907cc37bd549fc Mon Sep 17 00:00:00 2001 From: Sakura Ryoko Date: Mon, 1 Jul 2024 21:59:49 -0400 Subject: [PATCH] Fix: Item Frame floor / ceiling Yaw values. --- .../litematica/util/SchematicPlacingUtils.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/fi/dy/masa/litematica/util/SchematicPlacingUtils.java b/src/main/java/fi/dy/masa/litematica/util/SchematicPlacingUtils.java index 8e9e111a41..5d68d811b9 100644 --- a/src/main/java/fi/dy/masa/litematica/util/SchematicPlacingUtils.java +++ b/src/main/java/fi/dy/masa/litematica/util/SchematicPlacingUtils.java @@ -11,11 +11,14 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.decoration.AbstractDecorationEntity; import net.minecraft.entity.decoration.DisplayEntity; +import net.minecraft.entity.decoration.ItemFrameEntity; import net.minecraft.entity.decoration.painting.PaintingEntity; import net.minecraft.fluid.Fluid; import net.minecraft.inventory.Inventory; import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtList; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockRotation; @@ -36,6 +39,7 @@ import fi.dy.masa.litematica.schematic.container.LitematicaBlockStateContainer; import fi.dy.masa.litematica.schematic.placement.SchematicPlacement; import fi.dy.masa.litematica.schematic.placement.SubRegionPlacement; +import fi.dy.masa.malilib.util.Constants; import fi.dy.masa.malilib.util.IntBoundingBox; import fi.dy.masa.malilib.util.NBTUtils; @@ -385,6 +389,7 @@ public static void placeEntitiesToWorldWithinChunk(World world, ChunkPos chunkPo double x = pos.x + offX; double y = pos.y + offY; double z = pos.z + offZ; + float[] origRot = new float[2]; if (x >= minX && x < maxX && z >= minZ && z < maxZ) { @@ -412,6 +417,10 @@ public static void placeEntitiesToWorldWithinChunk(World world, ChunkPos chunkPo tag.putInt("TileZ", (int) p.z); } + NbtList rotation = tag.getList("Rotation", Constants.NBT.TAG_FLOAT); + origRot[0] = rotation.getFloat(0); + origRot[1] = rotation.getFloat(1); + Entity entity = EntityUtils.createEntityAndPassengersFromNBT(tag, world); if (entity != null) @@ -448,6 +457,14 @@ public static void placeEntitiesToWorldWithinChunk(World world, ChunkPos chunkPo entity.setPosition(x, y, z); } + if (entity instanceof ItemFrameEntity frameEntity) + { + if (frameEntity.getYaw() != origRot[0] && (frameEntity.getPitch() == 90.0F || frameEntity.getPitch() == -90.0F)) + { + // Fix Yaw only if Pitch is +/- 90.0F (Floor, Ceiling mounted) + frameEntity.setYaw(origRot[0]); + } + } EntityUtils.spawnEntityAndPassengersInWorld(entity, world);