Skip to content

block send logic seemingly ran twice for applyPhysics=false? #12871

@BenchmarkMode

Description

@BenchmarkMode

Expected behavior

Cratblock.setBlockState()

 if (applyPhysics) {
            return world.setBlock(pos, newState, net.minecraft.world.level.block.Block.UPDATE_ALL);
        } else {
            boolean success = world.setBlock(pos, newState,
                net.minecraft.world.level.block.Block.UPDATE_CLIENTS |
                    net.minecraft.world.level.block.Block.UPDATE_KNOWN_SHAPE |
                    net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE);
            if (success && world instanceof net.minecraft.world.level.Level) {
                world.getMinecraftWorld().sendBlockUpdated(
                    pos,
                    oldState,
                    newState,
                    net.minecraft.world.level.block.Block.UPDATE_ALL
                );
            }
            return success;
        }
    }

in setBlock it eventually checks for flag UPDATE_CLIENTS then runs sendBlockUpdated, so why do we run it again right after?

 if ((flags & UPDATE_CLIENTS) != 0 && (!this.isClientSide || (flags & UPDATE_INVISIBLE) == 0) && (this.isClientSide || chunkAt == null || (chunkAt.getFullStatus() != null && chunkAt.getFullStatus().isOrAfter(FullChunkStatus.FULL)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement // Paper - rewrite chunk system - change from ticking to full
                this.sendBlockUpdated(pos, blockState, state, flags);
            }
 if (success && world instanceof net.minecraft.world.level.Level) {
                world.getMinecraftWorld().sendBlockUpdated(
                    pos,
                    oldState,
                    newState,
                    net.minecraft.world.level.block.Block.UPDATE_ALL
                );
            }

this only happens when applyPhysics=false

Paper version

782ce95

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions