<commit_before>package net.tropicraft.core.common.dimension.feature;

import com.mojang.datafixers.Dynamic;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.IWorldWriter;
import net.minecraft.world.gen.IWorldGenerationReader;
import net.minecraft.world.gen.feature.AbstractTreeFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import net.tropicraft.core.common.block.TropicraftBlocks;

import java.util.ArrayList;
import java.util.Random;
import java.util.Set;
import java.util.function.Function;

public abstract class RainforestTreeFeature extends AbstractTreeFeature<NoFeatureConfig> {

    /**Used in placeBlockLine*/
    protected static final byte otherCoordPairs[] = {2, 0, 0, 1, 2, 1};

    public RainforestTreeFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> func, boolean doesNotifyOnPlace) {
        super(func, doesNotifyOnPlace);
    }

    protected void setState(Set<BlockPos> changedBlocks, IWorldWriter world, BlockPos pos, BlockState state, MutableBoundingBox bb) {
        setBlockStateInternally(world, pos, state);
        bb.expandTo(new MutableBoundingBox(pos, pos));
        if (BlockTags.LOGS.contains(state.getBlock())) {
            changedBlocks.add(pos.toImmutable());
        }
    }

    private void setBlockStateInternally(IWorldWriter world, BlockPos pos, BlockState state) {
        if (this.doBlockNotify) {
            world.setBlockState(pos, state, 19);
        } else {
            world.setBlockState(pos, state, 18);
        }
    }

    // TODO use rainforest sapling, if applicable
    protected net.minecraftforge.common.IPlantable getSapling() {
        return sapling;
    }

    protected final BlockState getLeaf() {
        return TropicraftBlocks.KAPOK_LEAVES.get().getDefaultState();
    }
    
    protected final BlockState getLog() {
        return TropicraftBlocks.MAHOGANY_LOG.get().getDefaultState();
    }

    protected void placeLeaf(final Set<BlockPos> changedBlocks, final IWorldGenerationReader world, final MutableBoundingBox bb, int x, int y, int z) {
        setState(changedBlocks, world, new BlockPos(x, y, z), getLeaf(), bb);
    }

    protected void placeLog(final Set<BlockPos> changedBlocks, final IWorldGenerationReader world, final MutableBoundingBox bb, int x, int y, int z) {
        setState(changedBlocks, world, new BlockPos(x, y, z), getLog(), bb);
    }

    protected boolean genCircle(IWorldGenerationReader world, int x, int y, int z, double outerRadius, double innerRadius, BlockState state, boolean solid) {
        return genCircle(world, new BlockPos(x, y, z), outerRadius, innerRadius, state, solid);
    }

    protected boolean genVines(final IWorldGenerationReader world, final Random rand, int i, int j, int k) {
        int m = 2;

        do {<commit_msg>Fix rainforest tree features not using correct sapling<commit_after>package net.tropicraft.core.common.dimension.feature;

import com.mojang.datafixers.Dynamic;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.IWorldWriter;
import net.minecraft.world.gen.IWorldGenerationReader;
import net.minecraft.world.gen.feature.AbstractTreeFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import net.tropicraft.core.common.block.TropicraftBlocks;

import java.util.ArrayList;
import java.util.Random;
import java.util.Set;
import java.util.function.Function;

public abstract class RainforestTreeFeature extends AbstractTreeFeature<NoFeatureConfig> {

    /**Used in placeBlockLine*/
    protected static final byte otherCoordPairs[] = {2, 0, 0, 1, 2, 1};

    public RainforestTreeFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> func, boolean doesNotifyOnPlace) {
        super(func, doesNotifyOnPlace);
    }

    protected void setState(Set<BlockPos> changedBlocks, IWorldWriter world, BlockPos pos, BlockState state, MutableBoundingBox bb) {
        setBlockStateInternally(world, pos, state);
        bb.expandTo(new MutableBoundingBox(pos, pos));
        if (BlockTags.LOGS.contains(state.getBlock())) {
            changedBlocks.add(pos.toImmutable());
        }
    }

    private void setBlockStateInternally(IWorldWriter world, BlockPos pos, BlockState state) {
        if (this.doBlockNotify) {
            world.setBlockState(pos, state, 19);
        } else {
            world.setBlockState(pos, state, 18);
        }
    }

    protected net.minecraftforge.common.IPlantable getSapling() {
        return TropicraftBlocks.MAHOGANY_SAPLING.get();
    }

    protected final BlockState getLeaf() {
        return TropicraftBlocks.KAPOK_LEAVES.get().getDefaultState();
    }
    
    protected final BlockState getLog() {
        return TropicraftBlocks.MAHOGANY_LOG.get().getDefaultState();
    }

    protected void placeLeaf(final Set<BlockPos> changedBlocks, final IWorldGenerationReader world, final MutableBoundingBox bb, int x, int y, int z) {
        setState(changedBlocks, world, new BlockPos(x, y, z), getLeaf(), bb);
    }

    protected void placeLog(final Set<BlockPos> changedBlocks, final IWorldGenerationReader world, final MutableBoundingBox bb, int x, int y, int z) {
        setState(changedBlocks, world, new BlockPos(x, y, z), getLog(), bb);
    }

    protected boolean genCircle(IWorldGenerationReader world, int x, int y, int z, double outerRadius, double innerRadius, BlockState state, boolean solid) {
        return genCircle(world, new BlockPos(x, y, z), outerRadius, innerRadius, state, solid);
    }

    protected boolean genVines(final IWorldGenerationReader world, final Random rand, int i, int j, int k) {
        int m = 2;

        do {
{'fraction_non_alphanumeric': 0.09848862315230028, 'fraction_numerical': 0.0036538780933399765, 'mean_word_length': 4.005818786367414, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4336741', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1755, 'n_words': 441}