faulty casts of templated classes

This commit is contained in:
Nikita Edel
2026-03-11 03:45:56 +01:00
parent e76ec32824
commit caadcfe9db
4 changed files with 33 additions and 18 deletions

View File

@@ -109,13 +109,15 @@ void ConsoleSchematicFile::load(DataInputStream *dis)
}
// READ TAGS //
// 4jcraft, fixed cast of templated List to get the tag list
// and cast it to CompoundTag inside the loop
CompoundTag *tag = NbtIo::read(dis);
ListTag<CompoundTag> *tileEntityTags = (ListTag<CompoundTag> *) tag->getList(L"TileEntities");
ListTag<Tag> *tileEntityTags = tag->getList(L"TileEntities");
if (tileEntityTags != NULL)
{
for (int i = 0; i < tileEntityTags->size(); i++)
{
CompoundTag *teTag = tileEntityTags->get(i);
CompoundTag *teTag = (CompoundTag*) tileEntityTags->get(i);
std::shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
if(te == NULL)
@@ -131,18 +133,23 @@ void ConsoleSchematicFile::load(DataInputStream *dis)
}
}
}
ListTag<CompoundTag> *entityTags = (ListTag<CompoundTag> *) tag->getList(L"Entities");
// 4jcraft, fixed cast of templated List to get the tag list
// and cast it to CompoundTag inside the loop
ListTag<Tag> *entityTags = tag->getList(L"Entities");
if (entityTags != NULL)
{
for (int i = 0; i < entityTags->size(); i++)
{
CompoundTag *eTag = entityTags->get(i);
CompoundTag *eTag = (CompoundTag*) entityTags->get(i);
eINSTANCEOF type = EntityIO::getType(eTag->getString(L"id"));
ListTag<DoubleTag> *pos = (ListTag<DoubleTag> *) eTag->getList(L"Pos");
double x = pos->get(0)->data;
double y = pos->get(1)->data;
double z = pos->get(2)->data;
// 4jcraft, same here
ListTag<Tag> *pos = eTag->getList(L"Pos");
double x = ((DoubleTag*) pos->get(0))->data;
double y = ((DoubleTag*) pos->get(1))->data;
double z = ((DoubleTag*) pos->get(2))->data;
if( type == eTYPE_PAINTING || type == eTYPE_ITEM_FRAME )
{