Skip to content

Commit

Permalink
Merge branch 'feature/1.20.1/leaves_optimization' into release/1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
supermassimo committed Dec 28, 2024
2 parents a15d0b0 + 7d4fc41 commit a784e6b
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 263 deletions.
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ dependencies {
runtimeOnly(fg.deobf("cc.tweaked:cc-tweaked-$mcVersion-core:${property("ccVersion")}"))
runtimeOnly(fg.deobf("cc.tweaked:cc-tweaked-$mcVersion-forge:${property("ccVersion")}"))

//Spark profiler
runtimeOnly(fg.deobf("curse.maven:spark-361579:4738952"))

// runtimeOnly(fg.deobf("com.harleyoconnor.suggestionproviderfix:SuggestionProviderFix-1.19:${property("suggestionProviderFixVersion")}"))
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
modName=DynamicTrees
modId=dynamictrees
modVersion=1.3.6
modVersion=1.4.0-BETA01

group=com.ferreusveritas.dynamictrees

Expand All @@ -17,7 +17,7 @@ ssVersion=5790633
gcVersion=5787839
jadeVersion=4986594

versionType=release
versionType=beta

# Path of update checker relative to version info file
updateCheckerPath=DynamicTrees.json
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public int getLightRequirement() {
}

@Override
public boolean updateTick(Level level, BlockPos pos, BlockState state, RandomSource rand) {
public boolean updateTick(LevelAccessor level, BlockPos pos, BlockState state, RandomSource rand) {
return false;
}
}.setRegistryName(DTTrees.NULL).setBlockRegistryName(DTTrees.NULL);
Expand Down Expand Up @@ -583,7 +583,7 @@ public BlockBehaviour.Properties getDefaultBlockProperties(final MapColor mapCol
///////////////////////////////////////////


public boolean updateTick(Level level, BlockPos pos, BlockState state, RandomSource rand) {
public boolean updateTick(LevelAccessor level, BlockPos pos, BlockState state, RandomSource rand) {
return shouldAge(false, state);
}

Expand Down Expand Up @@ -629,6 +629,10 @@ public boolean isCompatibleLeaves(LeavesProperties leaves){
return this.getFamily() == leaves.getFamily();
}

protected int maxLeavesRecursion(){
return 256;
}

///////////////////////////////////////////
// LEAVES COLORS
///////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public SolidDynamicLeavesBlock(final LeavesProperties leavesProperties, final Pr
super(leavesProperties, properties);
}

@Override
public VoxelShape getBlockSupportShape(BlockState pState, BlockGetter pReader, BlockPos pPos) {
return Shapes.block();
}

@Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return Shapes.block();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.ferreusveritas.dynamictrees.systems.genfeature.context.PostGenerationContext;
import com.ferreusveritas.dynamictrees.systems.genfeature.context.PostGrowContext;
import com.ferreusveritas.dynamictrees.util.CoordUtils;
import com.ferreusveritas.dynamictrees.util.SafeChunkBounds;
import com.ferreusveritas.dynamictrees.util.SimpleVoxmap;
import com.ferreusveritas.dynamictrees.util.function.TetraFunction;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -48,13 +50,22 @@ protected GenFeatureConfiguration createDefaultConfiguration() {
.with(MAX_HEIGHT, 32)
.with(CAN_GROW_PREDICATE, (level, blockPos) ->
level.getRandom().nextFloat() <= VANILLA_GROW_CHANCE)
.with(PLACE_CHANCE, .4f)
.with(PLACE_CHANCE, .3f)
.with(MAX_COUNT, 4);
}

@Override
protected boolean postGenerate(GenFeatureConfiguration configuration, PostGenerationContext context) {
return this.placeShroomlightsInValidPlace(configuration, context.level(), context.pos(), true);
boolean placed = this.placeShroomlightsInValidPlace(configuration, context.level(), context.pos(), true);
if (placed){
//pulse the lower half of the
SimpleVoxmap leafMap = context.species().getLeavesProperties().getCellKit().getLeafCluster();
for (BlockPos endPos : context.endPoints()){
TreeHelper.ageVolume(context.level(), endPos.below(leafMap.getLenY()/2 +1), leafMap.getLenX() / 2, leafMap.getLenY() / 2 -1, 4, SafeChunkBounds.ANY_WG);
}
return true;
}
return false;
}

@Override
Expand All @@ -71,7 +82,7 @@ private boolean placeShroomlightsInValidPlace(GenFeatureConfiguration configurat
if (validSpaces == null) {
return false;
}
if (validSpaces.size() > 0) {
if (!validSpaces.isEmpty()) {
if (worldGen) {
int placed = 0;
for (BlockPos chosenSpace : validSpaces) {
Expand Down Expand Up @@ -106,11 +117,17 @@ private int getTreeHeight(LevelAccessor level, BlockPos rootPos, int maxHeight)
private List<BlockPos> findBranchPits(GenFeatureConfiguration configuration, LevelAccessor level, BlockPos rootPos, int maxHeight) {
int existingBlocks = 0;
List<BlockPos> validSpaces = new LinkedList<>();
boolean firstPit = true;
for (int y = 2; y < maxHeight; y++) {
BlockPos trunkPos = rootPos.above(y);
for (Direction dir : HORIZONTALS) {
BlockPos sidePos = trunkPos.relative(dir);
if ((level.isEmptyBlock(sidePos) || level.getBlockState(sidePos).getBlock() instanceof DynamicLeavesBlock) && TreeHelper.isBranch(level.getBlockState(sidePos.above()))) {
//skip the first layer so shroomlights don't block the wart
if (firstPit) {
firstPit = false;
break;
}
validSpaces.add(sidePos);
} else if (level.getBlockState(sidePos).getBlock() == configuration.get(SHROOMLIGHT_BLOCK)) {
existingBlocks++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.ferreusveritas.dynamictrees.DynamicTrees;
import com.ferreusveritas.dynamictrees.api.TreeHelper;
import com.ferreusveritas.dynamictrees.api.TreeRegistry;
import com.ferreusveritas.dynamictrees.api.cell.CellKit;
import com.ferreusveritas.dynamictrees.api.data.Generator;
import com.ferreusveritas.dynamictrees.api.data.SaplingStateGenerator;
import com.ferreusveritas.dynamictrees.api.data.SeedItemModelGenerator;
Expand Down Expand Up @@ -876,7 +877,7 @@ public LogsAndSticks getLogsAndSticks(NetVolumeNode.Volume volume, boolean silkT
public boolean handleVoluntaryDrops(Level level, List<BlockPos> endPoints, BlockPos rootPos, BlockPos treePos, int fertility) {
int tickSpeed = level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
if (tickSpeed > 0) {
double slowFactor = 3.0 / tickSpeed;//This is an attempt to normalize voluntary drop rates.
double slowFactor = 3.0 / tickSpeed; //This is to prevent high tick-speeds from spamming the floor with seeds
if (level.random.nextDouble() < slowFactor) {
final List<ItemStack> drops = getVoluntaryDrops(level, rootPos, fertility);

Expand Down Expand Up @@ -1450,7 +1451,7 @@ public boolean handleRot(LevelAccessor level, List<BlockPos> ends, BlockPos root
float rotChance = rotChance(level, endPos, level.getRandom(), radius);
if (branch.checkForRot(level, endPos, this, fertility, radius, level.getRandom(), rotChance, safeBounds != SafeChunkBounds.ANY) || radius != family.getPrimaryThickness()) {
if (safeBounds != SafeChunkBounds.ANY) { // worldgen
TreeHelper.ageVolume(level, endPos.below((leafMap.getLenZ() - 1) / 2), (leafMap.getLenX() - 1) / 2, leafMap.getLenY(), 2, safeBounds);
TreeHelper.ageVolume(level, endPos.below(leafMap.getCenter().getY()), leafMap.getLenX() / 2, leafMap.getLenY(), 2, safeBounds);
}
iter.remove(); // Prune out the rotted end points, so we don't spawn fruit from them.
}
Expand Down
16 changes: 8 additions & 8 deletions src/main/resources/trees/dynamictrees/species/crimson.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
"sapling": "dynamictrees:block/smartmodel/mushroom_round"
},
"features": [
"clear_volume",
"shroomlight",
{
"name": "bottom_flare",
"properties": {
"min_radius": 7
}
},
{
"name": "vines",
"properties": {
Expand All @@ -32,14 +40,6 @@
"max_length": 5,
"quantity": 7
}
},
"clear_volume",
"shroomlight",
{
"name": "bottom_flare",
"properties": {
"min_radius": 7
}
}
],
"lang_overrides": {
Expand Down
20 changes: 10 additions & 10 deletions src/main/resources/trees/dynamictrees/species/mega_crimson.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
"acceptable_soils": ["nether_soil_like", "fungus_like", "dirt_like"],
"acceptable_growth_blocks": ["crimson_nylium"],
"features": [
{
"name": "mound",
"properties": {
"mound_cutoff_radius": 999
}
},
"clear_volume",
"shroomlight",
"bottom_flare",
{
"name": "vines",
"properties": {
Expand All @@ -32,15 +41,6 @@
"max_length": 5,
"quantity": 7
}
},
{
"name": "mound",
"properties": {
"mound_cutoff_radius": 999
}
},
"clear_volume",
"shroomlight",
"bottom_flare"
}
]
}

0 comments on commit a784e6b

Please sign in to comment.