0

world: work around Minecraft lighting nonsense

Minecraft occasionally generates chunks which are not yet lit.
In the past, I'd have said to just make them not render, but these
can sometimes be large areas of the world.

Instead, render them with full bright SkyLight. This looks less bad
than whatever is stored in the SkyLight property in these cases.

Closes #1787, probably. Only one person bothered providing a sample file.
This commit is contained in:
Nicolas F
2020-06-25 18:55:48 +02:00
parent 0143ad63a6
commit d3a5786642

View File

@@ -1428,16 +1428,22 @@ class RegionSet(object):
# Turn the skylight array into a 16x16x16 matrix. The array comes # Turn the skylight array into a 16x16x16 matrix. The array comes
# packed 2 elements per byte, so we need to expand it. # packed 2 elements per byte, so we need to expand it.
try: try:
if 'SkyLight' in section: # Sometimes, Minecraft loves generating chunks with no light info.
skylight = numpy.frombuffer(section['SkyLight'], dtype=numpy.uint8) # These mostly appear to have those two properties, and in this case
skylight = skylight.reshape((16,16,8)) # we default to full-bright as it's less jarring to look at than all-black.
else: # Special case introduced with 1.14 if chunk_data.get("Status", "") == "spawn" and 'Lights' in chunk_data:
skylight = numpy.zeros((16,16,8), dtype=numpy.uint8) section['SkyLight'] = numpy.full((16,16,16), 255, dtype=numpy.uint8)
skylight_expanded = numpy.empty((16,16,16), dtype=numpy.uint8) else:
skylight_expanded[:,:,::2] = skylight & 0x0F if 'SkyLight' in section:
skylight_expanded[:,:,1::2] = (skylight & 0xF0) >> 4 skylight = numpy.frombuffer(section['SkyLight'], dtype=numpy.uint8)
del skylight skylight = skylight.reshape((16,16,8))
section['SkyLight'] = skylight_expanded else: # Special case introduced with 1.14
skylight = numpy.zeros((16,16,8), dtype=numpy.uint8)
skylight_expanded = numpy.empty((16,16,16), dtype=numpy.uint8)
skylight_expanded[:,:,::2] = skylight & 0x0F
skylight_expanded[:,:,1::2] = (skylight & 0xF0) >> 4
del skylight
section['SkyLight'] = skylight_expanded
# Turn the BlockLight array into a 16x16x16 matrix, same as SkyLight # Turn the BlockLight array into a 16x16x16 matrix, same as SkyLight
if 'BlockLight' in section: if 'BlockLight' in section: