Skip to content

Commit

Permalink
Fixed both feet producing footsteps when landing when they shouldn't #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Jun 28, 2022
1 parent fa2b7ca commit ad279e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected void simulateJumping(LivingEntity ply) {
if (variator.EVENT_ON_JUMP) {
if (motionTracker.getHorizontalSpeed() < variator.SPEED_TO_JUMP_AS_MULTIFOOT) {
// STILL JUMP
playMultifoot(ply, getOffsetMinus(ply) + 0.4d, State.LAND);
playMultifoot(ply, getOffsetMinus(ply) + 0.4d, State.WANDER);
// 2 - 0.7531999805212d (magic number for vertical offset?)
} else {
playSinglefoot(ply, getOffsetMinus(ply) + 0.4d, State.JUMP, isRightFoot);
Expand All @@ -273,7 +273,7 @@ protected void simulateLanding(LivingEntity ply) {
// Always assume the player lands on their two feet
// Do not toggle foot:
// After landing sounds, the first foot will be same as the one used to jump.
} else if (/* !this.stepThisFrame && */!ply.isSneaking()) {
} else if (/* !this.stepThisFrame &&*/ !ply.isSneaking()) {
playSinglefoot(ply, getOffsetMinus(ply), motionTracker.pickState(ply, State.CLIMB, State.CLIMB_RUN), isRightFoot);
if (!this.stepThisFrame)
isRightFoot = !isRightFoot;
Expand Down Expand Up @@ -322,9 +322,13 @@ protected void playMultifoot(LivingEntity ply, double verticalOffsetAsMinus, Sta
Association leftFoot = solver.findAssociation(ply, verticalOffsetAsMinus, false);
Association rightFoot = solver.findAssociation(ply, verticalOffsetAsMinus, true);

if (leftFoot.hasAssociation() && leftFoot.equals(rightFoot)) {
if (leftFoot.dataEquals(rightFoot)) {
// If the two feet solve to the same sound, except NO_ASSOCIATION, only play the sound once
rightFoot = Association.NOT_EMITTER;
if (isRightFoot) {
leftFoot = Association.NOT_EMITTER;
} else {
rightFoot = Association.NOT_EMITTER;
}
}

solver.playAssociation(ply, leftFoot, eventType);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/eu/ha3/presencefootsteps/world/Association.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package eu.ha3.presencefootsteps.world;

import java.util.Objects;

import org.jetbrains.annotations.Nullable;

import net.minecraft.block.BlockState;
Expand Down Expand Up @@ -79,4 +81,8 @@ public BlockPos getPos() {
public BlockSoundGroup getSoundGroup() {
return blockState.getSoundGroup();
}

public boolean dataEquals(Association other) {
return hasAssociation() && Objects.equals(data, other.data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@
{
"type": "delayed",
"delay": 50,
"vol_min": 60,
"vol_max": 70,
"name": "grass.grass_run"
}
]
Expand Down

0 comments on commit ad279e1

Please sign in to comment.