attempt to make the game no crash when resetting chunks. Lighting gonna get fixed later I presume

This commit is contained in:
gnembon committed 2023-05-03 21:50:37 +02:00
1 parent 334f1060a5
commit 9cae675ede
3 files changed
+17 -26

No files matched your search

@@ -26,7 +26,7 @@ public abstract class BlockLightSectionStorage_scarpetChunkCreationMixin extends
@Override
public void processRelight(final LightEngine<?, ?> lightProvider, final long cPos)
{
final DynamicGraphMinFixedPoint_resetChunkInterface levelPropagator = (DynamicGraphMinFixedPoint_resetChunkInterface) lightProvider;
//final DynamicGraphMinFixedPoint_resetChunkInterface levelPropagator = (DynamicGraphMinFixedPoint_resetChunkInterface) lightProvider.;
for (int y = -1; y < 17; ++y)
{
@@ -53,11 +53,12 @@ public abstract class BlockLightSectionStorage_scarpetChunkCreationMixin extends
for (int dy = 0; dy < 16; ++dy)
{
final long dst = BlockPos.offset(pos, ox + t * dx, dy, oz + t * dz);
final long src = BlockPos.offset(dst, dir);
lightProvider.checkBlock(BlockPos.of(dst));
//final long src = BlockPos.offset(dst, dir);
final int srcLevel = ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborLightArray, src);
//final int srcLevel = ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborLightArray, src);
levelPropagator.cmInvokeUpdateLevel(src, dst, levelPropagator.cmCallGetPropagatedLevel(src, dst, srcLevel), true);
//levelPropagator.cmInvokeUpdateLevel(src, dst, levelPropagator.cmCallGetPropagatedLevel(src, dst, srcLevel), true);
}
}
}
@@ -62,7 +62,7 @@ public abstract class SkyLightSectionStorage_scarpetChunkCreationMixin extends L
@Override
public void processRelight(final LightEngine<?, ?> lightProvider, final long cPos)
{
final DynamicGraphMinFixedPoint_resetChunkInterface levelPropagator = (DynamicGraphMinFixedPoint_resetChunkInterface) lightProvider;
//final DynamicGraphMinFixedPoint_resetChunkInterface levelPropagator = (DynamicGraphMinFixedPoint_resetChunkInterface) lightProvider;
for (int y = -1; y < 17; ++y)
{
@@ -102,17 +102,18 @@ public abstract class SkyLightSectionStorage_scarpetChunkCreationMixin extends L
for (int dy = 0; dy < 16; ++dy)
{
final long dst = BlockPos.offset(pos, ox + t * dx, dy, oz + t * dz);
long src = BlockPos.offset(dst, dir);
//long src = BlockPos.offset(dst, dir);
long adj_src = (neighborLightArray != null)
? src
: BlockPos.asLong(BlockPos.getX(src), neighbourY, BlockPos.getZ(src));
//long adj_src = (neighborLightArray != null)
// ? src
// : BlockPos.asLong(BlockPos.getX(src), neighbourY, BlockPos.getZ(src));
final int srcLevel = neighborCeilingLightArray != null
? ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, adj_src)
: emptyLightLevel;
//final int srcLevel = neighborCeilingLightArray != null
// ? ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborCeilingLightArray, adj_src)
// : emptyLightLevel;
levelPropagator.cmInvokeUpdateLevel(src, dst, levelPropagator.cmCallGetPropagatedLevel(src, dst, srcLevel), true);
lightProvider.checkBlock(BlockPos.of(dst));
//levelPropagator.cmInvokeUpdateLevel(src, dst, levelPropagator.cmCallGetPropagatedLevel(src, dst, srcLevel), true);
}
}
}
@@ -35,8 +35,6 @@ public abstract class ThreadedLevelLightEngine_scarpetChunkCreationMixin extends
@Final
private ChunkMap chunkMap;
//@Shadow public abstract void propagateLightSources(final ChunkPos chunkPos);
@Override
@Invoker("updateChunkStatus")
public abstract void invokeUpdateChunkStatus(ChunkPos pos);
@@ -61,22 +59,13 @@ public abstract class ThreadedLevelLightEngine_scarpetChunkCreationMixin extends
final ChunkPos pos = chunk.getPos();
propagateLightSources(pos);
/*this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> {
super.setLightEnabled(pos, true);
this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> {
chunk.findBlockLightSources((lightPos, state) -> {
final int lightEmission = state.getLightEmission();
enqueueIncrease(lightPos.asLong(), LightEngine.QueueEntry.increaseLightFromEmission(lightEmission, isEmptyShape(state)));
});
chunk.getLights().forEach(
blockPos -> super.onBlockEmissionIncrease(blockPos, chunk.getLightEmission(blockPos))
);
((Lighting_scarpetChunkCreationInterface) this).relight(SectionPos.getZeroNode(SectionPos.asLong(pos.x, 0, pos.z)));
},
() -> "Relight chunk " + pos
));*/
));
return CompletableFuture.runAsync(
Util.name(() -> {