Skip to content

Commit

Permalink
fixed poplar seeds not getting registered if disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
supermassimo committed Apr 7, 2021
1 parent 400cd5d commit 43cb1a4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
13 changes: 11 additions & 2 deletions src/main/java/dynamictreesbop/trees/species/SpeciesPeach.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import biomesoplenty.common.block.BlockBOPLeaves;
import com.ferreusveritas.dynamictrees.ModBlocks;
import com.ferreusveritas.dynamictrees.api.TreeHelper;
import com.ferreusveritas.dynamictrees.api.TreeRegistry;
import com.ferreusveritas.dynamictrees.entities.EntityFallingTree;
import com.ferreusveritas.dynamictrees.models.ModelEntityFallingTree;
import com.ferreusveritas.dynamictrees.seasons.SeasonHelper;
import com.ferreusveritas.dynamictrees.systems.featuregen.FeatureGenFruit;
import com.ferreusveritas.dynamictrees.trees.Species;
import com.ferreusveritas.dynamictrees.trees.TreeFamily;
import com.ferreusveritas.dynamictrees.util.SafeChunkBounds;
import dynamictreesbop.DynamicTreesBOP;
import dynamictreesbop.ModConfigs;
import dynamictreesbop.ModContent;
Expand Down Expand Up @@ -54,14 +56,21 @@ public SpeciesPeach(TreeFamily treeFamily) {

addDropCreator(new DropCreatorFruit(BOPItems.peach));

//this causes fruit trees to turn back to oak if they are disabled
setRequiresTileEntity(ModConfigs.enablePeachTrees);
setRequiresTileEntity(true);

treeFamily.addConnectableVanillaLeaves((state) -> state.getBlock() instanceof BlockBOPLeaves && state.getValue(((BlockBOPLeaves) state.getBlock()).variantProperty) == BOPTrees.FLOWERING);

addGenFeature(new FeatureGenFruit(ModContent.peachFruit).setRayDistance(4));
}

@Override
public boolean generate(World world, BlockPos rootPos, Biome biome, Random random, int radius, SafeChunkBounds safeBounds) {
if (ModConfigs.enablePeachTrees)
return super.generate(world, rootPos, biome, random, radius, safeBounds);
Species def = TreeRegistry.findSpecies(new ResourceLocation(DynamicTreesBOP.MODID, ModContent.FLOWERINGOAK));
return def.generate(world, rootPos, biome, random, radius, safeBounds);
}

@Override
public float seasonalFruitProductionFactor(World world, BlockPos pos) {
float offset = fruitingOffset;
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/dynamictreesbop/trees/species/SpeciesPear.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import biomesoplenty.common.block.BlockBOPLeaves;
import com.ferreusveritas.dynamictrees.ModBlocks;
import com.ferreusveritas.dynamictrees.api.TreeHelper;
import com.ferreusveritas.dynamictrees.api.TreeRegistry;
import com.ferreusveritas.dynamictrees.seasons.SeasonHelper;
import com.ferreusveritas.dynamictrees.systems.featuregen.FeatureGenFruit;
import com.ferreusveritas.dynamictrees.trees.Species;
import com.ferreusveritas.dynamictrees.trees.TreeFamily;
import com.ferreusveritas.dynamictrees.util.SafeChunkBounds;
import dynamictreesbop.DynamicTreesBOP;
import dynamictreesbop.ModConfigs;
import dynamictreesbop.ModContent;
Expand Down Expand Up @@ -41,15 +43,21 @@ public SpeciesPear(TreeFamily treeFamily) {

addDropCreator(new DropCreatorFruit(BOPItems.pear));

//this causes fruit trees to turn back to oak if they are disabled
setRequiresTileEntity(ModConfigs.enablePearTrees);
setRequiresTileEntity(true);

treeFamily.addConnectableVanillaLeaves((state) -> state.getBlock() instanceof BlockBOPLeaves && state.getValue(((BlockBOPLeaves) state.getBlock()).variantProperty) == BOPTrees.DEAD);

//TODO: replace with pear
addGenFeature(new FeatureGenFruit(ModContent.pearFruit).setRayDistance(4).setFruitingRadius(4));
}

@Override
public boolean generate(World world, BlockPos rootPos, Biome biome, Random random, int radius, SafeChunkBounds safeBounds) {
if (ModConfigs.enablePearTrees)
return super.generate(world, rootPos, biome, random, radius, safeBounds);
return treeFamily.getCommonSpecies().generate(world, rootPos, biome, random, radius, safeBounds);
}

@Override
public float seasonalFruitProductionFactor(World world, BlockPos pos) {
float offset = fruitingOffset;
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/dynamictreesbop/trees/species/SpeciesPersimmon.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import biomesoplenty.common.block.BlockBOPLeaves;
import com.ferreusveritas.dynamictrees.ModBlocks;
import com.ferreusveritas.dynamictrees.api.TreeHelper;
import com.ferreusveritas.dynamictrees.api.TreeRegistry;
import com.ferreusveritas.dynamictrees.seasons.SeasonHelper;
import com.ferreusveritas.dynamictrees.systems.featuregen.FeatureGenFruit;
import com.ferreusveritas.dynamictrees.trees.Species;
import com.ferreusveritas.dynamictrees.trees.TreeFamily;
import com.ferreusveritas.dynamictrees.util.SafeChunkBounds;
import dynamictreesbop.DynamicTreesBOP;
import dynamictreesbop.ModConfigs;
import dynamictreesbop.ModContent;
Expand Down Expand Up @@ -42,8 +44,7 @@ public SpeciesPersimmon(TreeFamily treeFamily) {

addDropCreator(new DropCreatorFruit(BOPItems.persimmon));

//this causes fruit trees to turn back to oak if they are disabled
setRequiresTileEntity(ModConfigs.enablePersimmonTrees);
setRequiresTileEntity(true);

leavesProperties.setTree(treeFamily);

Expand All @@ -58,6 +59,14 @@ public int getQuantity(boolean worldGen) {
}.setRayDistance(4));
}

@Override
public boolean generate(World world, BlockPos rootPos, Biome biome, Random random, int radius, SafeChunkBounds safeBounds) {
if (ModConfigs.enablePersimmonTrees)
return super.generate(world, rootPos, biome, random, radius, safeBounds);
Species def = TreeRegistry.findSpecies(new ResourceLocation(DynamicTreesBOP.MODID, ModContent.OAKDYING));
return def.generate(world, rootPos, biome, random, radius, safeBounds);
}

@Override
public float seasonalFruitProductionFactor(World world, BlockPos pos) {
float offset = fruitingOffset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,6 @@ public ItemStack getSeedStack(int qty) {
return super.getSeedStack(qty);
return getFamily().getCommonSpecies().getSeedStack(qty);
}

@Override
public Seed getSeed() {
if (ModConfigs.enablePoplarSeeds)
return super.getSeed();
return getFamily().getCommonSpecies().getSeed();
}

@Override
public int maxBranchRadius() {
Expand Down

0 comments on commit 43cb1a4

Please sign in to comment.