Skip to content

Commit

Permalink
Fixed sounds playing for blocks that they shouldn't
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Mar 9, 2024
1 parent f233eb9 commit d154618
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public SoundsKey get(BlockPos pos, BlockState state, String substrate) {
getForState(state, substrate)
|| (!baseState.isAir() && (
getForState(baseState, substrate)
|| (!Substrates.DEFAULT.equals(substrate) && getForState(baseState, Substrates.DEFAULT))
|| getForPrimitive(baseState)
|| (!Substrates.isDefault(substrate) && getForState(baseState, Substrates.DEFAULT))
|| (getForPrimitive(baseState, substrate))
))
|| getForPrimitive(state)
|| getForPrimitive(state, substrate)
)) {
return association;
}
Expand All @@ -93,7 +93,10 @@ private boolean getForState(BlockState state, String substrate) {
return (association = engine.getIsolator().blocks().getAssociation(state, substrate)).isResult();
}

private boolean getForPrimitive(BlockState state) {
private boolean getForPrimitive(BlockState state, String substrate) {
if (Substrates.isSupplimentary(substrate)) {
return false;
}
BlockSoundGroup sounds = state.getSoundGroup();
return (association = engine.getIsolator().primitives().getAssociation(sounds.getStepSound(), PrimitiveLookup.getSubstrate(sounds))).isResult();
}
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/eu/ha3/presencefootsteps/world/PFSolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.World;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class PFSolver implements Solver {
private static final Logger LOGGER = LogManager.getLogger("PFSolver");

private static final double TRAP_DOOR_OFFSET = 0.1;

private final SoundEngine engine;
Expand Down Expand Up @@ -217,7 +213,6 @@ private Association findAssociation(AssociationPool associations, LivingEntity e
SoundsKey wetAssociation = SoundsKey.UNASSIGNED;

if (isValidCarpet && (association = associations.get(pos, carpet, Substrates.CARPET)).isEmitter()) {
LOGGER.debug("Carpet detected: " + association);
target = carpet;
// reference frame moved up by 1
} else {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/eu/ha3/presencefootsteps/world/Substrates.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
package eu.ha3.presencefootsteps.world;

import java.util.Set;

public interface Substrates {
String DEFAULT = "";
String CARPET = "carpet";
String WET = "wet";
String FENCE = "bigger";
String FOLIAGE = "foliage";
String MESSY = "messy";

Set<String> SUPPLIMENTART_SUBSTRATES = Set.of(WET, FOLIAGE, MESSY);

static boolean isDefault(String substrate) {
return Substrates.DEFAULT.equals(substrate);
}

static boolean isSupplimentary(String substrate) {
return SUPPLIMENTART_SUBSTRATES.contains(substrate);
}
}

0 comments on commit d154618

Please sign in to comment.