ItemTranslator: Fixed log items not displaying correctly on the client

closes #5724

this uses a (potentially bogus) assumption that the lowest mapped meta value associated with an ID is valid. I don't want to break this during a patch release, and this works for now.

In the future it would probably make more sense to bypass ItemTranslator entirely, and rely solely on the blockstate returned by RuntimeBlockMapping to fetch the correct ID. This is similar to how we serialize items for saving on disk in PM5.
This commit is contained in:
Dylan K. Taylor 2023-04-28 13:54:40 +01:00
parent 023460db2c
commit b70ff32548
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -110,6 +110,12 @@ final class ItemTranslator{
//new item without a fixed legacy ID - we can't handle this right now
continue;
}
if(isset($complexMappings[$newId]) && $complexMappings[$newId][0] === $intId && $complexMappings[$newId][1] <= $meta){
//TODO: HACK! Multiple legacy ID/meta pairs can be mapped to the same new ID (see minecraft:log)
//Assume that the first one is the most relevant for now
//However, this could catch fire in the future if this assumption is broken
continue;
}
$complexMappings[$newId] = [$intId, (int) $meta];
}
}