diff --git a/src/main/java/carpet/fakes/ServerLightingProviderInterface.java b/src/main/java/carpet/fakes/ServerLightingProviderInterface.java index c6858f9e..d8eb5ba4 100644 --- a/src/main/java/carpet/fakes/ServerLightingProviderInterface.java +++ b/src/main/java/carpet/fakes/ServerLightingProviderInterface.java @@ -1,10 +1,11 @@ package carpet.fakes; import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.chunk.Chunk; public interface ServerLightingProviderInterface { void publicUpdateChunkStatus(ChunkPos pos); void flush(); - void resetLight(ChunkPos pos); + void resetLight(Chunk chunk, ChunkPos pos); } diff --git a/src/main/java/carpet/mixins/ServerLightingProvider_scarpetMixin.java b/src/main/java/carpet/mixins/ServerLightingProvider_scarpetMixin.java index fadf44ad..b55e2236 100644 --- a/src/main/java/carpet/mixins/ServerLightingProvider_scarpetMixin.java +++ b/src/main/java/carpet/mixins/ServerLightingProvider_scarpetMixin.java @@ -6,7 +6,9 @@ import net.minecraft.server.world.ServerLightingProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.ChunkSectionPos; +import net.minecraft.world.IWorld; import net.minecraft.world.LightType; +import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.ChunkNibbleArray; import net.minecraft.world.chunk.ChunkProvider; import net.minecraft.world.chunk.light.LightingProvider; @@ -28,14 +30,14 @@ public abstract class ServerLightingProvider_scarpetMixin extends LightingProvid } @Override - public void resetLight(ChunkPos chpos) + public void resetLight(Chunk chunk, ChunkPos pos) { //super.setRetainData(pos, false); //super.setLightEnabled(pos, false); - for (int x = chpos.x-1; x <= chpos.x+1; x++ ) - for (int z = chpos.z-1; z <= chpos.z+1; z++ ) + //for (int x = chpos.x-1; x <= chpos.x+1; x++ ) + // for (int z = chpos.z-1; z <= chpos.z+1; z++ ) { - ChunkPos pos = new ChunkPos(x, z); + //ChunkPos pos = new ChunkPos(x, z); int j; for(j = -1; j < 17; ++j) { super.queueData(LightType.BLOCK, ChunkSectionPos.from(pos, j), new ChunkNibbleArray()); @@ -44,6 +46,17 @@ public abstract class ServerLightingProvider_scarpetMixin extends LightingProvid for(j = 0; j < 16; ++j) { super.updateSectionStatus(ChunkSectionPos.from(pos, j), true); } + + super.setLightEnabled(pos, true); + + chunk.getLightSourcesStream().forEach((blockPos) -> { + super.addLightSource(blockPos, chunk.getLuminance(blockPos)); + }); + } + + + + } } diff --git a/src/main/java/carpet/script/CarpetExpression.java b/src/main/java/carpet/script/CarpetExpression.java index eefc7875..7a244270 100644 --- a/src/main/java/carpet/script/CarpetExpression.java +++ b/src/main/java/carpet/script/CarpetExpression.java @@ -2955,7 +2955,9 @@ public class CarpetExpression BlockArgument locator = BlockArgument.findIn(cc, lv, 0); BlockPos pos = locator.block.getPos(); ServerWorld world = cc.s.getWorld(); - ((ServerLightingProviderInterface)world.getChunkManager().getLightingProvider()).resetLight(new ChunkPos(pos)); //light(world.getChunk(pos), false); + ((ServerLightingProviderInterface)world.getChunkManager().getLightingProvider()).resetLight(world.getChunk(pos), new ChunkPos(pos)); //light(world.getChunk(pos), false); + forceChunkUpdate(pos, world); + world.getChunkManager().getLightingProvider().light(world.getChunk(pos), false); return LazyValue.TRUE; });