Skip to content

Commit

Permalink
Fix: Item Frame floor / ceiling Yaw values.
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Jul 2, 2024
1 parent 0da6cd6 commit e83b9b7
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit e83b9b7

Please sign in to comment.