fix: item frames & paintings

now to finish all the blockstates..
This commit is contained in:
Fireblade
2026-05-03 23:04:21 -04:00
parent bcb6fb9db1
commit 0ee913e6e2
8 changed files with 73 additions and 43 deletions
+5 -1
View File
@@ -15,6 +15,7 @@ AddPaintingPacket::AddPaintingPacket()
z = 0;
dir = 0;
motive = L"";
placedByPlayer = false;
}
AddPaintingPacket::AddPaintingPacket(shared_ptr<Painting> e)
@@ -25,6 +26,7 @@ AddPaintingPacket::AddPaintingPacket(shared_ptr<Painting> e)
z = e->zTile;
dir = e->dir;
motive = e->motive->name;
placedByPlayer = e->placedByPlayer;
}
void AddPaintingPacket::read(DataInputStream *dis) //throws IOException
@@ -35,6 +37,7 @@ void AddPaintingPacket::read(DataInputStream *dis) //throws IOException
y = dis->readInt();
z = dis->readInt();
dir = dis->readInt();
placedByPlayer = dis->readByte() != 0;
}
void AddPaintingPacket::write(DataOutputStream *dos) //throws IOException
@@ -45,6 +48,7 @@ void AddPaintingPacket::write(DataOutputStream *dos) //throws IOException
dos->writeInt(y);
dos->writeInt(z);
dos->writeInt(dir);
dos->writeByte(placedByPlayer ? 1 : 0);
}
void AddPaintingPacket::handle(PacketListener *listener)
@@ -54,5 +58,5 @@ void AddPaintingPacket::handle(PacketListener *listener)
int AddPaintingPacket::getEstimatedSize()
{
return 24;
return 25;
}
+1
View File
@@ -12,6 +12,7 @@ public:
int x, y, z;
int dir;
wstring motive;
bool placedByPlayer;
public:
AddPaintingPacket();
@@ -604,6 +604,7 @@ int CompressedTileStorage::get(int x, int y, int z)
int block, tile;
getBlockAndTile( &block, &tile, x, y, z );
if (blockIndices[block] == 0) return 0;
int indexType = blockIndices[block] & INDEX_TYPE_MASK;
if( indexType == INDEX_TYPE_0_OR_8_BIT )
+37 -39
View File
@@ -68,7 +68,7 @@ void HangingEntity::setDir(int dir)
int offset = 0;
// set offset to 1 if player is stock world (not auto generated) (FIXME AS IT DOESNT WORK)
// set offset to 1 if placed in stock world
if (level->isClientSide && !placedByPlayer)
{
offset = 1;
@@ -90,10 +90,10 @@ void HangingEntity::setDir(int dir)
float ss = -(0.5f / 16.0f);
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) originalZ -= fOffs - offset;
if (dir == Direction::WEST) originalX -= fOffs - offset;
if (dir == Direction::SOUTH) originalZ += fOffs - offset;
if (dir == Direction::EAST) originalX += fOffs - offset;
if (dir == Direction::NORTH) originalX -= offs(getWidth());
if (dir == Direction::WEST) originalZ += offs(getWidth());
if (dir == Direction::SOUTH) originalX += offs(getWidth());
@@ -127,11 +127,10 @@ void HangingEntity::tick()
if (checkInterval++ == 20 * 5 && !level->isClientSide)
{
checkInterval = 0;
if (!removed && !survives())
if (!removed && !survives() && placedByPlayer)
{
// TODO: apply same non-player placed checks here
// remove();
// dropItem(nullptr);
remove();
dropItem(nullptr);
}
}
}
@@ -297,40 +296,39 @@ void HangingEntity::readAdditionalSaveData(CompoundTag *tag)
setPos(xTile, yTile, zTile);
}
if (tag->contains(L"Direction"))
{
dir = tag->getByte(L"Direction");
setDir(dir);
return;
}
if (tag->contains(L"Facing"))
{
int f = tag->getByte(L"Facing");
dir = Direction::from2DDataValue(f);
setDir(dir);
return;
}
// fallback for legacy system
if (tag->contains(L"Dir"))
{
switch (tag->getByte(L"Dir"))
{
case 0: dir = Direction::NORTH; break;
case 1: dir = Direction::WEST; break;
case 2: dir = Direction::SOUTH; break;
case 3: dir = Direction::EAST; break;
}
setDir(dir);
}
if (tag->contains(L"PlacedByPlayer"))
{
placedByPlayer = tag->getByte(L"PlacedByPlayer") == 1;
}
bool hasDir = false;
if (tag->contains(L"Direction"))
{
dir = tag->getByte(L"Direction");
hasDir = true;
}
else if (tag->contains(L"Facing"))
{
int f = tag->getByte(L"Facing");
dir = Direction::from2DDataValue(f);
hasDir = true;
}
else if (tag->contains(L"Dir"))
{
switch (tag->getByte(L"Dir"))
{
case 0: dir = Direction::NORTH; break;
case 1: dir = Direction::WEST; break;
case 2: dir = Direction::SOUTH; break;
case 3: dir = Direction::EAST; break;
}
hasDir = true;
}
if (hasDir)
{
setDir(dir);
}
}
bool HangingEntity::repositionEntityAfterLoad()
+3
View File
@@ -67,6 +67,7 @@ shared_ptr<HangingEntity> HangingEntityItem::createEntity(Level *level, int x, i
if (eType == eTYPE_PAINTING)
{
shared_ptr<Painting> painting = std::make_shared<Painting>(level, x, y, z, dir);
painting->placedByPlayer = true;
#ifndef _CONTENT_PACKAGE
if (app.DebugArtToolsOn() && auxValue > 0)
@@ -84,6 +85,8 @@ shared_ptr<HangingEntity> HangingEntityItem::createEntity(Level *level, int x, i
else if (eType == eTYPE_ITEM_FRAME)
{
shared_ptr<ItemFrame> itemFrame = std::make_shared<ItemFrame>(level, x, y, z, dir);
itemFrame->placedByPlayer = true;
itemFrame->setDir(dir);
return dynamic_pointer_cast<HangingEntity> (itemFrame);
}