|
2 | 2 |
|
3 | 3 | import dev.ryanhcode.sable.SableConfig; |
4 | 4 | import dev.ryanhcode.sable.api.SubLevelAssemblyHelper; |
| 5 | +import dev.ryanhcode.sable.api.sublevel.SubLevelContainer; |
5 | 6 | import dev.ryanhcode.sable.companion.math.BoundingBox3i; |
6 | 7 | import dev.ryanhcode.sable.companion.math.BoundingBox3ic; |
7 | 8 | import dev.ryanhcode.sable.sublevel.ServerSubLevel; |
8 | 9 | import dev.ryanhcode.sable.sublevel.plot.HeatDataChunkSection; |
9 | 10 | import dev.ryanhcode.sable.sublevel.plot.LevelPlot; |
10 | 11 | import dev.ryanhcode.sable.sublevel.plot.PlotChunkHolder; |
| 12 | +import dev.ryanhcode.sable.sublevel.storage.SubLevelRemovalReason; |
11 | 13 | import it.unimi.dsi.fastutil.ints.Int2ObjectMap; |
12 | 14 | import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; |
13 | 15 | import it.unimi.dsi.fastutil.ints.IntArrayList; |
@@ -237,7 +239,15 @@ private void split() { |
237 | 239 | listener.addBlocks(level, bounds, blocks); |
238 | 240 | } |
239 | 241 |
|
240 | | - SubLevelAssemblyHelper.assembleBlocks((ServerLevel) level, blocks.get(0), blocks, bounds); |
| 242 | + final ServerSubLevel subLevel = SubLevelAssemblyHelper.assembleBlocks((ServerLevel) level, blocks.get(0), blocks, bounds); |
| 243 | + |
| 244 | + // Protect against split sub-levels that have zero mass. |
| 245 | + if (subLevel.getMassTracker().getCenterOfMass() == null || subLevel.getMassTracker().getMass() <= 0.0) { |
| 246 | + subLevel.getPlot().destroyAllBlocks(); |
| 247 | + |
| 248 | + final SubLevelContainer container = Objects.requireNonNull(SubLevelContainer.getContainer(level)); |
| 249 | + container.removeSubLevel(subLevel, SubLevelRemovalReason.REMOVED); |
| 250 | + } |
241 | 251 | } |
242 | 252 | } |
243 | 253 |
|
|
0 commit comments