<commit_before>package com.InfinityRaider.settlercraft.settlement;

import com.InfinityRaider.settlercraft.SettlerCraft;
import com.InfinityRaider.settlercraft.api.v1.*;
import com.InfinityRaider.settlercraft.reference.Names;
import com.InfinityRaider.settlercraft.settlement.building.BuildingRegistry;
import com.InfinityRaider.settlercraft.settlement.settler.EntitySettler;
import com.InfinityRaider.settlercraft.settlement.settler.profession.ProfessionRegistry;
import com.InfinityRaider.settlercraft.settlement.settler.profession.builder.StructureBuildProgress;
import com.InfinityRaider.settlercraft.settlement.settler.profession.builder.TaskBuildBuilding;
import com.InfinityRaider.settlercraft.utility.AbstractEntityFrozen;
import com.InfinityRaider.settlercraft.utility.BoundingBox;
import com.InfinityRaider.settlercraft.utility.LogHelper;
import com.InfinityRaider.settlercraft.utility.schematic.Schematic;
import com.InfinityRaider.settlercraft.utility.schematic.SchematicReader;
import com.InfinityRaider.settlercraft.utility.schematic.SchematicRotationTransformer;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class SettlementBuilding extends AbstractEntityFrozen implements ISettlementBuilding {
    private int id;
    private int settlementId;
    private ISettlement settlement;
    private IBuilding building;
    private BoundingBox boundingBox;
    private BlockPos origin;
    private BlockPos home;
    private int rotation;
    private StructureBuildProgress buildProgress;
    private IInventorySerializable inventory;
    private List<EntitySettler> inhabitants;

    public SettlementBuilding(World world) {
        super(world);
        this.inhabitants = new ArrayList<>();
    }

    public SettlementBuilding(ISettlement settlement, BlockPos pos, IBuilding building, Schematic schematic, int rotation) {
        this(settlement.world());
        this.id = -1;
        this.settlementId = settlement.id();
        this.settlement = settlement;
        this.building = building;
        this.boundingBox = schematic.getBoundingBox(pos, rotation);
        this.origin = pos;
        this.home = SchematicRotationTransformer.getInstance().applyRotation(pos, schematic.home[0], schematic.home[1], schematic.home[2], rotation);
        this.rotation = rotation;
        this.buildProgress = new StructureBuildProgress(getWorld(), pos, schematic, rotation);
        this.inventory = building.getDefaultInventory();
        this.posX = this.prevPosX = this.home.getX() + 0.5;
        this.posY = this.prevPosY = this.home.getY() + 0.5;
        this.posZ = this.prevPosZ = this.home.getZ() + 0.5;
    }

    @Override
    protected String name() {
        return building().name();
    }

    @Override
    protected void update() {
        if(isComplete() && building() != null && building().needsUpdateTicks()) {
            building().onUpdateTick(this);
        }
    }

    @Override
    protected void onEntitySpawned() {
        ISettlement settlement = this.settlement();
        if(settlement == null) {
            SettlementHandler.getInstance().addBuildingToBuffer(settlementId, this);
        } else {
            settlement.onBuildingUpdated(this);
        }
    }

    @Override
    protected void onChunkLoaded() {
        onEntitySpawned();
    }

    @Override
    public int id() {
        return id;
    }

    @Override
    public IBuilding building() {
        return building;
    }

    @Override
    public boolean canDoWorkHere(ISettler settler) {
        if(settler == null) {
            return false;
        }
        if(settler.profession() == ProfessionRegistry.getInstance().BUILDER) {
            return settlement() != null
                    && settler.profession() == ProfessionRegistry.getInstance().BUILDER
                    && !getBuildProgress().isComplete();
        }
        return building().canSettlerWorkHere(this, settler);
    }

    @Override
    public ITask getTaskForSettler(ISettler settler) {
        if(this.isComplete()) {
            return building().getTaskForSettler(this, settler);
        } else {
            return new TaskBuildBuilding(this.settlement(), settler, this, this.getBuildProgress());
        }
    }

    @Override
    public List<? extends ISettler> inhabitants() {
        return null;
    }

    @Override
    public ISettlement settlement() {
        if(settlement == null) {
            this.settlement = SettlementHandler.getInstance().getSettlement(settlementId);
        }
        return settlement;
    }

    @Override
    public boolean canLiveHere(ISettler settler) {
        return isComplete() && inhabitants().size() < building.maxInhabitants();
    }<commit_msg>fix oversight after merge<commit_after>package com.InfinityRaider.settlercraft.settlement;

import com.InfinityRaider.settlercraft.SettlerCraft;
import com.InfinityRaider.settlercraft.api.v1.*;
import com.InfinityRaider.settlercraft.reference.Names;
import com.InfinityRaider.settlercraft.settlement.building.BuildingRegistry;
import com.InfinityRaider.settlercraft.settlement.settler.EntitySettler;
import com.InfinityRaider.settlercraft.settlement.settler.profession.ProfessionRegistry;
import com.InfinityRaider.settlercraft.settlement.settler.profession.builder.StructureBuildProgress;
import com.InfinityRaider.settlercraft.settlement.settler.profession.builder.TaskBuildBuilding;
import com.InfinityRaider.settlercraft.utility.AbstractEntityFrozen;
import com.InfinityRaider.settlercraft.utility.BoundingBox;
import com.InfinityRaider.settlercraft.utility.LogHelper;
import com.InfinityRaider.settlercraft.utility.schematic.Schematic;
import com.InfinityRaider.settlercraft.utility.schematic.SchematicReader;
import com.InfinityRaider.settlercraft.utility.schematic.SchematicRotationTransformer;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class SettlementBuilding extends AbstractEntityFrozen implements ISettlementBuilding {
    private int id;
    private int settlementId;
    private ISettlement settlement;
    private IBuilding building;
    private BoundingBox boundingBox;
    private BlockPos origin;
    private BlockPos home;
    private int rotation;
    private StructureBuildProgress buildProgress;
    private IInventorySerializable inventory;
    private List<EntitySettler> inhabitants;

    public SettlementBuilding(World world) {
        super(world);
        this.inhabitants = new ArrayList<>();
    }

    public SettlementBuilding(ISettlement settlement, BlockPos pos, IBuilding building, Schematic schematic, int rotation) {
        this(settlement.world());
        this.id = -1;
        this.settlementId = settlement.id();
        this.settlement = settlement;
        this.building = building;
        this.boundingBox = schematic.getBoundingBox(pos, rotation);
        this.origin = pos;
        this.home = SchematicRotationTransformer.getInstance().applyRotation(pos, schematic.home[0], schematic.home[1], schematic.home[2], rotation);
        this.rotation = rotation;
        this.buildProgress = new StructureBuildProgress(getWorld(), pos, schematic, rotation);
        this.inventory = building.getDefaultInventory();
        this.posX = this.prevPosX = this.home.getX() + 0.5;
        this.posY = this.prevPosY = this.home.getY() + 0.5;
        this.posZ = this.prevPosZ = this.home.getZ() + 0.5;
    }

    @Override
    protected String name() {
        return building().name();
    }

    @Override
    protected void update() {
        if(isComplete() && building() != null && building().needsUpdateTicks()) {
            building().onUpdateTick(this);
        }
    }

    @Override
    protected void onEntitySpawned() {
        ISettlement settlement = this.settlement();
        if(settlement == null) {
            SettlementHandler.getInstance().addBuildingToBuffer(settlementId, this);
        } else {
            settlement.onBuildingUpdated(this);
        }
    }

    @Override
    protected void onChunkLoaded() {
        onEntitySpawned();
    }

    @Override
    public int id() {
        return id;
    }

    @Override
    public IBuilding building() {
        return building;
    }

    @Override
    public boolean canDoWorkHere(ISettler settler) {
        if(settler == null) {
            return false;
        }
        if(settler.profession() == ProfessionRegistry.getInstance().BUILDER) {
            return settlement() != null
                    && settler.profession() == ProfessionRegistry.getInstance().BUILDER
                    && !getBuildProgress().isComplete();
        }
        return building().canSettlerWorkHere(this, settler);
    }

    @Override
    public ITask getTaskForSettler(ISettler settler) {
        if(this.isComplete()) {
            return building().getTaskForSettler(this, settler);
        } else {
            return new TaskBuildBuilding(this.settlement(), settler, this, this.getBuildProgress());
        }
    }

    @Override
    public List<? extends ISettler> inhabitants() {
        return inhabitants;
    }

    @Override
    public ISettlement settlement() {
        if(settlement == null) {
            this.settlement = SettlementHandler.getInstance().getSettlement(settlementId);
        }
        return settlement;
    }

    @Override
    public boolean canLiveHere(ISettler settler) {
        return isComplete() && inhabitants().size() < building.maxInhabitants();
    }
{'fraction_non_alphanumeric': 0.09990787183949228, 'fraction_numerical': 0.0022520217013000305, 'mean_word_length': 3.2926186291739894, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3231780', 'n_tokens_mistral': 2909, 'n_tokens_neox': 2706, 'n_words': 507}