<commit_before>/*
 * This file is part of Sponge, licensed under the MIT License (MIT).
 *
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.spongepowered.common.world;

import com.google.common.base.MoreObjects;
import org.spongepowered.api.world.BlockChangeFlag;
import org.spongepowered.common.event.tracking.BlockChangeFlagManager;
import org.spongepowered.common.util.Constants;

/**
 * A flag of sorts that determines whether a block change will perform various
 * interactions, such as notifying neighboring blocks, performing block physics
 * on placement, etc.
 */
public final class SpongeBlockChangeFlag implements BlockChangeFlag {

    private final boolean updateNeighbors;
    private final boolean notifyClients;
    private final boolean performBlockPhysics;
    private final boolean notifyObservers;
    private final boolean ignoreRender;
    private final boolean forceReRender;
    private final boolean blockMoving;
    private final boolean lighting;
    private final boolean pathfindingUpdates;
    private final boolean neighborDrops;
    private final int rawFlag;
    private final String name;

    public SpongeBlockChangeFlag(final String name, final int flag) {
        this.updateNeighbors = (flag & Constants.BlockChangeFlags.NEIGHBOR_MASK) != 0; // 1
        this.notifyClients = (flag & Constants.BlockChangeFlags.NOTIFY_CLIENTS) != 0; // 2
        this.ignoreRender = (flag & Constants.BlockChangeFlags.IGNORE_RENDER) != 0; // 4
        this.forceReRender = (flag & Constants.BlockChangeFlags.FORCE_RE_RENDER) != 0 && !this.ignoreRender; // 8
        this.notifyObservers = (flag & Constants.BlockChangeFlags.DENY_NEIGHBOR_SHAPE_UPDATE) == 0; // 16
        this.neighborDrops = (flag & Constants.BlockChangeFlags.NEIGHBOR_DROPS) != 0; // 32
        this.blockMoving = (flag & Constants.BlockChangeFlags.BLOCK_MOVING) != 0; // 64
        this.performBlockPhysics = (flag & Constants.BlockChangeFlags.PHYSICS_MASK) == 0; // sponge
        this.lighting = (flag & Constants.BlockChangeFlags.LIGHTING_UPDATES) == 0; // sponge
        this.pathfindingUpdates = (flag & Constants.BlockChangeFlags.PATHFINDING_UPDATES) == 0; // sponge
        this.rawFlag = flag;
        this.name = name;
    }

    @Override
    public boolean updateNeighbors() {
        return this.updateNeighbors;
    }

    @Override
    public boolean notifyClients() {
        return this.notifyClients;
    }

    @Override
    public boolean performBlockPhysics() {
        return this.performBlockPhysics;
    }

    @Override
    public boolean notifyObservers() {
        return this.notifyObservers;
    }

    @Override
    public boolean updateLighting() {
        return this.lighting;
    }

    @Override
    public boolean notifyPathfinding() {
        return this.pathfindingUpdates;
    }

    @Override
    public SpongeBlockChangeFlag withUpdateNeighbors(final boolean updateNeighbors) {
        if (this.updateNeighbors == updateNeighbors) {
            return this;
        }
        final int maskedFlag =
            (updateNeighbors ? Constants.BlockChangeFlags.NEIGHBOR_MASK : 0)
                | (this.notifyClients ? Constants.BlockChangeFlags.NOTIFY_CLIENTS : 0)
                | (this.ignoreRender ? Constants.BlockChangeFlags.IGNORE_RENDER : 0)
                | (this.forceReRender ? Constants.BlockChangeFlags.FORCE_RE_RENDER : 0)
                | (this.notifyObservers ? 0 : Constants.BlockChangeFlags.DENY_NEIGHBOR_SHAPE_UPDATE)
                | (this.neighborDrops ? Constants.BlockChangeFlags.NEIGHBOR_DROPS : 0)
                | (this.blockMoving ? Constants.BlockChangeFlags.BLOCK_MOVING : 0)
                | (this.performBlockPhysics ? 0 : Constants.BlockChangeFlags.PHYSICS_MASK)
                | (this.lighting ? 0 : Constants.BlockChangeFlags.LIGHTING_UPDATES)
                | (this.pathfindingUpdates ? 0 : Constants.BlockChangeFlags.PATHFINDING_UPDATES);
        return BlockChangeFlagManager.fromNativeInt(maskedFlag);
    }

    @Override
    public BlockChangeFlag withNotifyClients(final boolean notifyClients) {
        if (this.notifyClients == notifyClients) {
            return this;
        }
        final int maskedFlag =
                (this.updateNeighbors ? Constants.BlockChangeFlags.NEIGHBOR_MASK : 0)
                        | (this.notifyClients ? Constants.BlockChangeFlags.NOTIFY_CLIENTS : 0)
                        | (this.ignoreRender ? Constants.BlockChangeFlags.IGNORE_RENDER : 0)
                        | (this.forceReRender ? Constants.BlockChangeFlags.FORCE_RE_RENDER : 0)
                        | (this.notifyObservers ? 0 : Constants.BlockChangeFlags.DENY_NEIGHBOR_SHAPE_UPDATE)
                        | (this.neighborDrops ? Constants.BlockChangeFlags.NEIGHBOR_DROPS : 0)
                        | (this.blockMoving ? Constants.BlockChangeFlags.BLOCK_MOVING : 0)
                        | (performBlockPhysics ? 0 : Constants.BlockChangeFlags.PHYSICS_MASK)
                        | (this.lighting ? 0 : Constants.BlockChangeFlags.LIGHTING_UPDATES)
                        | (this.pathfindingUpdates ? 0 : Constants.BlockChangeFlags.PATHFINDING_UPDATES);
        return BlockChangeFlagManager.fromNativeInt(maskedFlag);
    }

    @Override
    public SpongeBlockChangeFlag withPhysics(final boolean performBlockPhysics) {
        if (this.performBlockPhysics == performBlockPhysics) {
            return this;
        }
        final int maskedFlag =
            (this.updateNeighbors ? Constants.BlockChangeFlags.NEIGHBOR_MASK : 0)
                | (this.notifyClients ? Constants.BlockChangeFlags.NOTIFY_CLIENTS : 0)
                | (this.ignoreRender ? Constants.BlockChangeFlags.IGNORE_RENDER : 0)
                | (this.forceReRender ? Constants.BlockChangeFlags.FORCE_RE_RENDER : 0)
                | (this.notifyObservers ? 0 : Constants.BlockChangeFlags.DENY_NEIGHBOR_SHAPE_UPDATE)
                | (this.neighborDrops ? Constants.BlockChangeFlags.NEIGHBOR_DROPS : 0)
                | (this.blockMoving ? Constants.BlockChangeFlags.BLOCK_MOVING : 0)
                | (performBlockPhysics ? 0 : Constants.BlockChangeFlags.PHYSICS_MASK)
                | (this.lighting ? 0 : Constants.BlockChangeFlags.LIGHTING_UPDATES)
                | (this.pathfindingUpdates ? 0 : Constants.BlockChangeFlags.PATHFINDING_UPDATES);
        return BlockChangeFlagManager.fromNativeInt(maskedFlag);
    }

    @Override<commit_msg>Use the correct variable for notify clients changes<commit_after>/*
 * This file is part of Sponge, licensed under the MIT License (MIT).
 *
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.spongepowered.common.world;

import com.google.common.base.MoreObjects;
import org.spongepowered.api.world.BlockChangeFlag;
import org.spongepowered.common.event.tracking.BlockChangeFlagManager;
import org.spongepowered.common.util.Constants;

/**
 * A flag of sorts that determines whether a block change will perform various
 * interactions, such as notifying neighboring blocks, performing block physics
 * on placement, etc.
 */
public final class SpongeBlockChangeFlag implements BlockChangeFlag {

    private final boolean updateNeighbors;
    private final boolean notifyClients;
    private final boolean performBlockPhysics;
    private final boolean notifyObservers;
    private final boolean ignoreRender;
    private final boolean forceReRender;
    private final boolean blockMoving;
    private final boolean lighting;
    private final boolean pathfindingUpdates;
    private final boolean neighborDrops;
    private final int rawFlag;
    private final String name;

    public SpongeBlockChangeFlag(final String name, final int flag) {
        this.updateNeighbors = (flag & Constants.BlockChangeFlags.NEIGHBOR_MASK) != 0; // 1
        this.notifyClients = (flag & Constants.BlockChangeFlags.NOTIFY_CLIENTS) != 0; // 2
        this.ignoreRender = (flag & Constants.BlockChangeFlags.IGNORE_RENDER) != 0; // 4
        this.forceReRender = (flag & Constants.BlockChangeFlags.FORCE_RE_RENDER) != 0 && !this.ignoreRender; // 8
        this.notifyObservers = (flag & Constants.BlockChangeFlags.DENY_NEIGHBOR_SHAPE_UPDATE) == 0; // 16
        this.neighborDrops = (flag & Constants.BlockChangeFlags.NEIGHBOR_DROPS) != 0; // 32
        this.blockMoving = (flag & Constants.BlockChangeFlags.BLOCK_MOVING) != 0; // 64
        this.performBlockPhysics = (flag & Constants.BlockChangeFlags.PHYSICS_MASK) == 0; // sponge
        this.lighting = (flag & Constants.BlockChangeFlags.LIGHTING_UPDATES) == 0; // sponge
        this.pathfindingUpdates = (flag & Constants.BlockChangeFlags.PATHFINDING_UPDATES) == 0; // sponge
        this.rawFlag = flag;
        this.name = name;
    }

    @Override
    public boolean updateNeighbors() {
        return this.updateNeighbors;
    }

    @Override
    public boolean notifyClients() {
        return this.notifyClients;
    }

    @Override
    public boolean performBlockPhysics() {
        return this.performBlockPhysics;
    }

    @Override
    public boolean notifyObservers() {
        return this.notifyObservers;
    }

    @Override
    public boolean updateLighting() {
        return this.lighting;
    }

    @Override
    public boolean notifyPathfinding() {
        return this.pathfindingUpdates;
    }

    @Override
    public SpongeBlockChangeFlag withUpdateNeighbors(final boolean updateNeighbors) {
        if (this.updateNeighbors == updateNeighbors) {
            return this;
        }
        final int maskedFlag =
            (updateNeighbors ? Constants.BlockChangeFlags.NEIGHBOR_MASK : 0)
                | (this.notifyClients ? Constants.BlockChangeFlags.NOTIFY_CLIENTS : 0)
                | (this.ignoreRender ? Constants.BlockChangeFlags.IGNORE_RENDER : 0)
                | (this.forceReRender ? Constants.BlockChangeFlags.FORCE_RE_RENDER : 0)
                | (this.notifyObservers ? 0 : Constants.BlockChangeFlags.DENY_NEIGHBOR_SHAPE_UPDATE)
                | (this.neighborDrops ? Constants.BlockChangeFlags.NEIGHBOR_DROPS : 0)
                | (this.blockMoving ? Constants.BlockChangeFlags.BLOCK_MOVING : 0)
                | (this.performBlockPhysics ? 0 : Constants.BlockChangeFlags.PHYSICS_MASK)
                | (this.lighting ? 0 : Constants.BlockChangeFlags.LIGHTING_UPDATES)
                | (this.pathfindingUpdates ? 0 : Constants.BlockChangeFlags.PATHFINDING_UPDATES);
        return BlockChangeFlagManager.fromNativeInt(maskedFlag);
    }

    @Override
    public SpongeBlockChangeFlag withNotifyClients(final boolean notifyClients) {
        if (this.notifyClients == notifyClients) {
            return this;
        }
        final int maskedFlag =
                (this.updateNeighbors ? Constants.BlockChangeFlags.NEIGHBOR_MASK : 0)
                        | (notifyClients ? Constants.BlockChangeFlags.NOTIFY_CLIENTS : 0)
                        | (this.ignoreRender ? Constants.BlockChangeFlags.IGNORE_RENDER : 0)
                        | (this.forceReRender ? Constants.BlockChangeFlags.FORCE_RE_RENDER : 0)
                        | (this.notifyObservers ? 0 : Constants.BlockChangeFlags.DENY_NEIGHBOR_SHAPE_UPDATE)
                        | (this.neighborDrops ? Constants.BlockChangeFlags.NEIGHBOR_DROPS : 0)
                        | (this.blockMoving ? Constants.BlockChangeFlags.BLOCK_MOVING : 0)
                        | (this.performBlockPhysics ? 0 : Constants.BlockChangeFlags.PHYSICS_MASK)
                        | (this.lighting ? 0 : Constants.BlockChangeFlags.LIGHTING_UPDATES)
                        | (this.pathfindingUpdates ? 0 : Constants.BlockChangeFlags.PATHFINDING_UPDATES);
        return BlockChangeFlagManager.fromNativeInt(maskedFlag);
    }

    @Override
    public SpongeBlockChangeFlag withPhysics(final boolean performBlockPhysics) {
        if (this.performBlockPhysics == performBlockPhysics) {
            return this;
        }
        final int maskedFlag =
            (this.updateNeighbors ? Constants.BlockChangeFlags.NEIGHBOR_MASK : 0)
                | (this.notifyClients ? Constants.BlockChangeFlags.NOTIFY_CLIENTS : 0)
                | (this.ignoreRender ? Constants.BlockChangeFlags.IGNORE_RENDER : 0)
                | (this.forceReRender ? Constants.BlockChangeFlags.FORCE_RE_RENDER : 0)
                | (this.notifyObservers ? 0 : Constants.BlockChangeFlags.DENY_NEIGHBOR_SHAPE_UPDATE)
                | (this.neighborDrops ? Constants.BlockChangeFlags.NEIGHBOR_DROPS : 0)
                | (this.blockMoving ? Constants.BlockChangeFlags.BLOCK_MOVING : 0)
                | (performBlockPhysics ? 0 : Constants.BlockChangeFlags.PHYSICS_MASK)
                | (this.lighting ? 0 : Constants.BlockChangeFlags.LIGHTING_UPDATES)
                | (this.pathfindingUpdates ? 0 : Constants.BlockChangeFlags.PATHFINDING_UPDATES);
        return BlockChangeFlagManager.fromNativeInt(maskedFlag);
    }

    @Override
{'fraction_non_alphanumeric': 0.07862796833773088, 'fraction_numerical': 0.006596306068601583, 'mean_word_length': 2.954355764214919, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3317531', 'n_tokens_mistral': 4479, 'n_tokens_neox': 4155, 'n_words': 1022}