Skip to content

Commit

Permalink
Merge pull request #15 from fonnymunkey/release/1.12.2
Browse files Browse the repository at this point in the history
Fix #14 and add tree collision volume scaling with repeated collisions
  • Loading branch information
ACGaming authored Jun 19, 2024
2 parents d754d9d + 5f142b0 commit c8738ee
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

public class AnimationHandlerFallover implements IAnimationHandler {

boolean fallSound = false;

@Override
public String getName() {
return "fallover";
Expand Down Expand Up @@ -110,14 +108,12 @@ public void handleMotion(EntityFallingTree entity) {
}

if (fallSpeed > 0 && testCollision(entity)) {
float fallSpeedPrev = fallSpeed;
addRotation(entity, -fallSpeed);//pull back to before the collision
getData(entity).bounces++;
fallSpeed *= -AnimationConstants.TREE_ELASTICITY;//bounce with elasticity
entity.landed = Math.abs(fallSpeed) < 0.02f;//The entity has landed if after a bounce it has little velocity
if (!fallSound) {
entity.world.playSound(null, entity.getPosition(), ModSoundEvents.TREE_LANDING, SoundCategory.AMBIENT, 0.8F, entity.world.rand.nextFloat());
fallSound = true;
}
if(fallSpeedPrev > 0.1F && !entity.world.isRemote) entity.world.playSound(null, entity.getPosition(), ModSoundEvents.TREE_LANDING, SoundCategory.AMBIENT, (Math.min(1.5F, fallSpeedPrev) / 1.5F) * 0.6F + 0.1F, entity.world.rand.nextFloat() * 0.2F + 0.6F);
}

//Crush living things with clumsy dead trees
Expand Down

0 comments on commit c8738ee

Please sign in to comment.