relight
This commit is contained in:
1 parent
ac9fcd9ece
commit
d9aa6f15ad
4 files changed
+65
No files matched your search
@@ -6,4 +6,5 @@ public interface ServerLightingProviderInterface
|
||||
{
|
||||
void publicUpdateChunkStatus(ChunkPos pos);
|
||||
void flush();
|
||||
void resetLight(ChunkPos pos);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.ServerLightingProviderInterface;
|
||||
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.LightType;
|
||||
import net.minecraft.world.chunk.ChunkNibbleArray;
|
||||
import net.minecraft.world.chunk.ChunkProvider;
|
||||
import net.minecraft.world.chunk.light.LightingProvider;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(ServerLightingProvider.class)
|
||||
public abstract class ServerLightingProvider_scarpetMixin extends LightingProvider implements ServerLightingProviderInterface
|
||||
{
|
||||
|
||||
@Shadow protected abstract void updateChunkStatus(ChunkPos pos);
|
||||
|
||||
|
||||
@Shadow public abstract void checkBlock(BlockPos pos);
|
||||
|
||||
public ServerLightingProvider_scarpetMixin(ChunkProvider chunkProvider, boolean hasBlockLight, boolean hasSkyLight)
|
||||
{
|
||||
super(chunkProvider, hasBlockLight, hasSkyLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetLight(ChunkPos chpos)
|
||||
{
|
||||
//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++ )
|
||||
{
|
||||
ChunkPos pos = new ChunkPos(x, z);
|
||||
int j;
|
||||
for(j = -1; j < 17; ++j) {
|
||||
super.queueData(LightType.BLOCK, ChunkSectionPos.from(pos, j), new ChunkNibbleArray());
|
||||
super.queueData(LightType.SKY, ChunkSectionPos.from(pos, j), new ChunkNibbleArray());
|
||||
}
|
||||
for(j = 0; j < 16; ++j) {
|
||||
super.updateSectionStatus(ChunkSectionPos.from(pos, j), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import carpet.fakes.ChunkTicketManagerInterface;
|
||||
import carpet.fakes.MinecraftServerInterface;
|
||||
import carpet.fakes.BiomeArrayInterface;
|
||||
import carpet.fakes.ServerChunkManagerInterface;
|
||||
import carpet.fakes.ServerLightingProviderInterface;
|
||||
import carpet.fakes.StatTypeInterface;
|
||||
import carpet.fakes.ThreadedAnvilChunkStorageInterface;
|
||||
import carpet.helpers.FeatureGenerator;
|
||||
@@ -2948,6 +2949,16 @@ public class CarpetExpression
|
||||
return (cc, tt) -> ret;
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("relight", -1, (c, t, lv) ->
|
||||
{
|
||||
CarpetContext cc = (CarpetContext) c;
|
||||
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);
|
||||
return LazyValue.TRUE;
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("current_dimension", 0, (c, t, lv) -> {
|
||||
ServerCommandSource s = ((CarpetContext)c).s;
|
||||
Value retval = new StringValue(NBTSerializableValue.nameFromRegistryId(Registry.DIMENSION_TYPE.getId(s.getWorld().dimension.getType())));
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
|
||||
"ThreadedAnvilChunkStorage_scarpetChunkCreationMixin",
|
||||
"ChunkHolder_scarpetChunkCreationMixin",
|
||||
"ServerLightingProvider_scarpetMixin",
|
||||
|
||||
"ChunkTicketManager_spawnChunksMixin",
|
||||
"ServerWorld_spawnChunksMixin",
|
||||
"ServerLightingProvider_scarpetChunkCreationMixin",
|
||||
|
||||
"ChunkTicketManager_spawnChunksMixin",
|
||||
|
||||
Reference in new issue
Block a user