Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Minecraft.World/HangingEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,16 @@ void HangingEntity::setDir(int dir)
float y = yTile + 0.5f;
float z = zTile + 0.5f;

float originalX = x;
float originalZ = z;

float fOffs = 0.5f + 1.0f / 16.0f;

if (this->GetType() == eTYPE_PAINTING)
{
fOffs = 0.5f + 1.0f / 32.0f; //dividing by 16.0f introduce a small gap between the block and the painting. See https://github.com/smartcmd/MinecraftConsoles/issues/661
}

if (dir == Direction::NORTH) z -= fOffs;
if (dir == Direction::WEST) x -= fOffs;
if (dir == Direction::SOUTH) z += fOffs;
Expand All @@ -76,6 +84,26 @@ void HangingEntity::setDir(int dir)

float ss = -(0.5f / 16.0f);

//dividing the fOffs by 32 breaks the BB and allow paintings to be placed on a block when they shouldn't
//so we need to modify the x and z to set their value as if the fOffs was divided by 16 and not 32
if (this->GetType() == eTYPE_PAINTING)
{
fOffs = 0.5f + 1.0f / 16.0f;
if (dir == Direction::NORTH) originalZ -= fOffs;
if (dir == Direction::WEST) originalX -= fOffs;
if (dir == Direction::SOUTH) originalZ += fOffs;
if (dir == Direction::EAST) originalX += fOffs;

if (dir == Direction::NORTH) originalX -= offs(getWidth());
if (dir == Direction::WEST) originalZ += offs(getWidth());
if (dir == Direction::SOUTH) originalX += offs(getWidth());
if (dir == Direction::EAST) originalZ -= offs(getWidth());

x = originalX;
z = originalZ;
}


// 4J Stu - Due to rotations the bb couold be set with a lower bound x/z being higher than the higher bound
float x0 = x - w - ss;
float x1 = x + w + ss;
Expand Down