Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/main/java/me/andre111/mambience/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ public static class ScannerConfig {
public static final int DEFAULT_ENTITY_SIZE_X = 33;
public static final int DEFAULT_ENTITY_SIZE_Y = 17;
public static final int DEFAULT_ENTITY_SIZE_Z = 33;

private int sizeX = DEFAULT_SIZE_X;
private int sizeY = DEFAULT_SIZE_Y;
private int sizeZ = DEFAULT_SIZE_X;
private int interval = DEFAULT_INTERVAL;
private int entitySizeX = DEFAULT_ENTITY_SIZE_X;
private int entitySizeY = DEFAULT_ENTITY_SIZE_Y;
private int entitySizeZ = DEFAULT_ENTITY_SIZE_Z;

public int getSizeX() {
return sizeX;
}
Expand Down Expand Up @@ -186,15 +186,15 @@ public static class AmbientEventsConfig {
public static final boolean DEFAULT_TRIGGER_ATTACK_SOUNDS = true;
public static final boolean DEFAULT_TRIGGER_USE_SOUNDS = true;
public static final boolean DEFAULT_TRIGGER_HELD_ITEM_SOUNDS = true;

private boolean enabled = DEFAULT_ENABLED;
private float volume = DEFAULT_VOLUME;
private boolean stopSounds = DEFAULT_STOP_SOUNDS;
private boolean disableWind = DEFAULT_DISABLE_WIND;
private boolean triggerAttackSounds = DEFAULT_TRIGGER_ATTACK_SOUNDS;
private boolean triggerUseSounds = DEFAULT_TRIGGER_USE_SOUNDS;
private boolean triggerHeldItemSounds = DEFAULT_TRIGGER_HELD_ITEM_SOUNDS;

public boolean isEnabled() {
return enabled;
}
Expand Down Expand Up @@ -286,11 +286,13 @@ public static class MovementConfig {
public static final boolean DEFAULT_FOOTSTEPS_ENABLED = true;
public static final boolean DEFAULT_ARMOR_ENABLED = true;
public static final float DEFAULT_VOLUME = 0.3f;

public static final boolean DEFAULT_APPLY_SUGGESTIONS = true;

private boolean footstepsEnabled = DEFAULT_FOOTSTEPS_ENABLED;
private boolean armorEnabled = DEFAULT_FOOTSTEPS_ENABLED;
private float volume = DEFAULT_VOLUME;

private boolean applySuggestedSounds = DEFAULT_APPLY_SUGGESTIONS;

public boolean footstepsEnabled() {
return footstepsEnabled;
}
Expand All @@ -309,5 +311,12 @@ public float getVolume() {
public void setVolume(float volume) {
this.volume = volume;
}

public boolean applySuggested() {
return applySuggestedSounds;
}
public void setApplySuggested(boolean enabled) {
this.applySuggestedSounds = enabled;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ private static void loadToMap(Map<String, List<FSMaterial>> map, JsonObject obj)
map.put(e.getKey(), Arrays.stream(e.getValue().getAsString().split(",")).map(id -> MaterialLoader.getMaterial(id)).toList());
}
}

public static void addBlock(String block, String type) {
BLOCK_MAP.put(block, Arrays.stream(type.split(",")).map(id -> MaterialLoader.getMaterial(id)).toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import me.andre111.mambience.MAmbience;
import me.andre111.mambience.data.loader.FootstepLoader;
import me.andre111.mambience.config.Config;
import net.minecraft.registry.Registries;
import net.minecraft.sound.BlockSoundGroup;

Expand Down Expand Up @@ -127,7 +128,11 @@ public static void scanForMissingBlockMapEntries() {
String id = Registries.BLOCK.getId(block).toString();
if(!FootstepLoader.BLOCK_MAP.containsKey(id)) {
String type = DEFAULT_SOUND_MAP.get(block.getDefaultState().getSoundGroup());
MAmbience.getLogger().error("\""+id+"\" is missing a footstep type entry - suggested: \""+type+"\"");
if (Config.movement().applySuggested() && type != null) {
FootstepLoader.addBlock(id, type);
} else {
MAmbience.getLogger().error("\""+id+"\" is missing a footstep type entry - suggested: \""+type+"\"");
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ public ConfigScreenFactory<?> getModConfigScreenFactory() {
.startIntSlider(Text.translatable("mambience.config.volume"), (int) (Config.movement().getVolume()*100), 0, 100)
.setDefaultValue((int) (Config.MovementConfig.DEFAULT_VOLUME*100))
.setSaveConsumer(i -> { Config.movement().setVolume(i/100.0f); })
.build())
.addEntry(entryBuilder
.startBooleanToggle(Text.translatable("mambience.config.apply_suggested"), Config.movement().applySuggested())
.setDefaultValue(Config.MovementConfig.DEFAULT_APPLY_SUGGESTIONS)
.setSaveConsumer(Config.movement()::setApplySuggested)
.build());

// Scanner
Expand Down Expand Up @@ -214,7 +219,7 @@ public ConfigScreenFactory<?> getModConfigScreenFactory() {
.setMax(65)
.setSaveConsumer(Config.scanner()::setEntitySizeZ)
.build());

return builder.build();
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public MixinLivingEntity(EntityType<?> type, World world) {

@SuppressWarnings("resource")
@Inject(at = @At(value = "HEAD"), method = "swingHand(Lnet/minecraft/util/Hand;Z)V", cancellable = true)
public void swingHand(Hand hand, boolean fromServerPlayer, CallbackInfo ci) {
private void swingHand(Hand hand, boolean fromServerPlayer, CallbackInfo ci) {
if(!this.handSwinging && hand == Hand.MAIN_HAND && (Object) this instanceof PlayerEntity) {
if(this.getWorld().isClient && !MAmbienceFabric.instance.runClientSide) return;

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/mambience/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

"mambience.config.enable": "Enabled",
"mambience.config.volume": "Volume Multiplier",

"mambience.config.apply_suggested": "Apply Suggested Sounds",

"mambience.config.sizex": "Size X",
"mambience.config.sizey": "Size Y",
"mambience.config.sizez": "Size Z",
Expand Down