Skip to content
Permalink
Browse files

Reduce light load a little, only relight when needed

  • Loading branch information...
kenzierocks committed Jul 23, 2019
1 parent 3bf45d6 commit c4caeac065d816fa52c2d0bf484dbe84b134bda7
Showing with 12 additions and 11 deletions.
  1. +12 −11 worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java
@@ -223,13 +223,7 @@ private int buildUpdateFlags(Collection<SideEffect> sideEffects) {
}

if (successful) {
int flags = buildUpdateFlags(sideEffects);
if (flags != 0) {
world.markAndNotifyBlock(pos, chunk, old, newState, flags);
}
if (sideEffects.contains(SideEffect.LIGHT)) {
world.getChunkProvider().getLightManager().checkBlock(pos);
}
applySideEffectsMc(sideEffects, world, chunk, pos, old, newState);
}

return successful;
@@ -246,16 +240,23 @@ public boolean applySideEffects(BlockVector3 position, BlockState previousType,
BlockPos pos = new BlockPos(x, y, z);
OptionalInt stateId = BlockStateIdAccess.getBlockStateId(previousType);
net.minecraft.block.BlockState prevState = stateId.isPresent() ? Block.getStateById(stateId.getAsInt()) : ForgeAdapter.adapt(previousType);
net.minecraft.block.BlockState newState = chunk.getBlockState(pos);

applySideEffectsMc(sideEffects, world, chunk, pos, prevState, newState);
return true;
}

private void applySideEffectsMc(Collection<SideEffect> sideEffects, World world,
Chunk chunk, BlockPos pos,
net.minecraft.block.BlockState prevState,
net.minecraft.block.BlockState newState) {
int flags = buildUpdateFlags(sideEffects);
if (flags != 0) {
world.markAndNotifyBlock(pos, chunk, prevState, chunk.getBlockState(pos), flags);
world.markAndNotifyBlock(pos, chunk, prevState, newState, flags);
}
if (sideEffects.contains(SideEffect.LIGHT)) {
if (sideEffects.contains(SideEffect.LIGHT) && prevState.getLightValue() != newState.getLightValue()) {
world.getChunkProvider().getLightManager().checkBlock(pos);
}

return true;
}

@Override

0 comments on commit c4caeac

Please sign in to comment.
You can’t perform that action at this time.