Skip to content

Commit

Permalink
hotfix saving tiles for new memory management; fixed leaves rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
wefhy committed Aug 9, 2022
1 parent a0fbf0a commit 2d5abc7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/java/dev/wefhy/whymap/WhyMapMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class WhyMapMod : ModInitializer {
ClientPlayConnectionEvents.DISCONNECT.register { handler, client ->
LOGGER.info("SAVING ALL DATA!!!")
activeWorld!!.close()
LOGGER.info("Saved all data")
activeWorld = null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ class ExperimentalTileGenerator {
)
} else {
g2d.color = java.awt.Color(block.material.color.color)

g2d.fillRect(x * 16, y * 16, (x + 1) * 16, (y + 1) * 16)
g2d.fillRect(x * 16, y * 16, 16, 16)
}
if (depth == 0.toByte()) continue
val sourceOverlay = ExperimentalTextureProvider.getBitmap(blockOverlay.block)
Expand All @@ -94,7 +93,7 @@ class ExperimentalTileGenerator {
(c + (-depth * 4)).toInt() or ((alpha * 255).toInt() shl 24),
true
)
g2d.fillRect(x * 16, y * 16, (x + 1) * 16, (y + 1) * 16)
g2d.fillRect(x * 16, y * 16, 16, 16)
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/dev/wefhy/whymap/tiles/region/MapRegionManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ class MapRegionManager {
}

private inline fun getOrPut(position: LocalTileRegion, defaultValue: () -> MapArea): MapArea {
return getLoadedOrCached(position)
?: run {
val value = defaultValue()
regions[position] = value
value
}
return regions.getOrPut(position) {
regionsWeakCache[position]?.get() ?: defaultValue()
}
}

private inline fun getOrPutWeak(position: LocalTileRegion, defaultValue: () -> MapArea?): MapArea? {
Expand Down Expand Up @@ -108,6 +105,7 @@ class MapRegionManager {
regions.clear()
regionsWeakCache.clear()
LOGGER.debug("SAVED ALL TILES!")
println("WhyMap: SAVED ALL TILES!")
}
}

Expand Down

0 comments on commit 2d5abc7

Please sign in to comment.