From 350b217a0a17e6392d226051966b7e8f4ca320c6 Mon Sep 17 00:00:00 2001 From: Max Hyper Date: Fri, 6 Sep 2024 19:23:48 -0300 Subject: [PATCH] added cap to particle count to prevent lag --- gradle.properties | 2 +- .../animation/FalloverAnimationHandler.java | 15 +++++++++++---- .../dynamictrees/init/DTConfigs.java | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 86a4165cd..ddb2aed8d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ modName=DynamicTrees modId=dynamictrees -modVersion=1.3.0 +modVersion=1.3.1 group=com.ferreusveritas.dynamictrees diff --git a/src/main/java/com/ferreusveritas/dynamictrees/entity/animation/FalloverAnimationHandler.java b/src/main/java/com/ferreusveritas/dynamictrees/entity/animation/FalloverAnimationHandler.java index c1c5c1239..62198128b 100644 --- a/src/main/java/com/ferreusveritas/dynamictrees/entity/animation/FalloverAnimationHandler.java +++ b/src/main/java/com/ferreusveritas/dynamictrees/entity/animation/FalloverAnimationHandler.java @@ -103,21 +103,28 @@ private Vec3 rotateAroundAxis(Vec3 in, Vec3 axis, double theta){ protected void flingLeavesParticles(FallingTreeEntity entity, float fallSpeed){ int bounces = getData(entity).bounces; if (bounces > 1) return; - double bounceDecay = Math.exp(-bounces); + int maxParticleBlocks = DTConfigs.MAX_FALLING_TREE_LEAVES_PARTICLES.get(); + if (maxParticleBlocks == 0) return; + double limitChance = 1; + if (entity.getDestroyData().getNumLeaves() > maxParticleBlocks){ + limitChance = maxParticleBlocks / (double)entity.getDestroyData().getNumLeaves(); + } + limitChance *= Math.exp(-bounces); BranchDestructionData data = entity.getDestroyData(); Direction.Axis toolAxis = data.toolDir.getAxis(); + int particleCount = bounces == 0 ? (int)(fallSpeed*5) : 1; if (toolAxis == Direction.Axis.Y) return; //this one isn't possible anyways Vec3 w = entity.getForward().scale(fallSpeed * data.toolDir.getAxisDirection().getStep()); if (toolAxis == Direction.Axis.X) w = new Vec3(w.z, w.x, w.y); - double speedVar = 0.2f * bounceDecay; + double speedVar = 0; RandomSource rand = entity.level().random; for (int i=0; i