Skip to content

Commit

Permalink
Update 0.4.2 (#136)
Browse files Browse the repository at this point in the history
* [#135] Compat with Nostalgia Tweaks

* Change how overlay manager is wired into Gui

* Ensure CREDITS.md is included in Jar

* Weight table cleanup; fog diagnostics; fix neoforge GUI layer registration

* Rework custom particles

* Refactor and arrangement for future port

* Remove unused/deleted import

* Diagnostic support for particle render collections

* Blockitem toolbar sounds; don't fog tint if biome fog disabled

* Tighten up weight table handling for morning fog

* AcousticCollection enhancement; morning fog weight tables

* Add whatsplaying subcommand to /dsmm

* Turn off block item toolbar by default; split music in seasons pack

* Split blocked sound processing from remap

* Sound remapping; adding a variety of step sound replacements

* Add organic block sounds; fixup block edge block detection

* Dirt paths and cauldrons

* Merging of sound mapping configs

* More robust merging of sound mapping rules; rug sound for wool steps

* Add compass wobble to unnatural dimensions

* Small optimization

---------

Co-authored-by: OreCruncher <[email protected]>
  • Loading branch information
OreCruncher and OreCruncher authored Jan 7, 2025
1 parent 4fbe3fa commit 0d352c7
Show file tree
Hide file tree
Showing 239 changed files with 1,914 additions and 525 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
> ### DynamicSurroundings-1.21.1-0.4.2
**All Loaders**
* JAVA 21+
* Architectury 13.0.8+

**Fabric**
* Fabric Loader >= 0.16.9
* Fabric API >= 0.110.0+1.21.

**NeoForge**
* NeoForge 21.1.84+

**What's New**
* Experimental: Toolbar sounds will play the "block step" sound for block items. It is off by default, and can be turned on in settings.
* Added whatsplaying subcommand to /dsmm. Will report on the music that is playing in the Music Manager.
* Work in Progress: Brought back a variety of block step sounds. Dynamic Surroundings will perform remapping of sound plays to get an updated sound, which is entirely different from the prior implementation. This is not intended to be full-featured as with prior step simulations. Can be disabled in the configuration (Sound Options -> Sound Remapping).

**Changes**
* Do not tint biome fog if biome fog effect is disabled.
* Compass overlay will spin wildly if the dimension is not natural, like the Nether. This mirrors vanilla compass behavior.
* Internal modifications and restructure to facilitate porting to MC 1.21.4. Mojang started its refactor for how component data is encoded, not to mention the always welcome "find out what was renamed and where it was moved to" game.

**Fixes**
* Disabling fog effect actually works
* Compatibility with Nostalgia Tweaks and Distant Horizons world fog effect

> ### DynamicSurroundings-1.21.1-0.4.1
**All Loaders**
* JAVA 21+
Expand Down
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ subprojects {
it.options.release = 21
}

tasks.register('copyJarToMain', Copy) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
if (project.name != "common" && project.name != "stubs") {
from remapJar
into "../build/libs"
}
}

// Configure Maven publishing.
publishing {
publications {
Expand Down
10 changes: 4 additions & 6 deletions common/src/main/java/org/orecruncher/dsurround/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.orecruncher.dsurround.commands.Commands;
import org.orecruncher.dsurround.config.libraries.*;
import org.orecruncher.dsurround.config.libraries.impl.*;
import org.orecruncher.dsurround.effects.particles.ParticleSheets;
import org.orecruncher.dsurround.gui.overlay.OverlayManager;
import org.orecruncher.dsurround.gui.keyboard.KeyBindings;
import org.orecruncher.dsurround.lib.GameUtils;
Expand All @@ -24,6 +23,8 @@
import org.orecruncher.dsurround.eventing.ClientState;
import org.orecruncher.dsurround.lib.registry.ReloadListener;
import org.orecruncher.dsurround.lib.resources.ResourceUtilities;
import org.orecruncher.dsurround.lib.seasons.ISeasonalInformation;
import org.orecruncher.dsurround.lib.seasons.SeasonManager;
import org.orecruncher.dsurround.lib.version.IVersionChecker;
import org.orecruncher.dsurround.lib.version.VersionChecker;
import org.orecruncher.dsurround.lib.version.VersionResult;
Expand Down Expand Up @@ -128,6 +129,8 @@ public void initializeClient() {
.registerSingleton(ISoundLibrary.class, SoundLibrary.class)
.registerSingleton(IBiomeLibrary.class, BiomeLibrary.class)
.registerSingleton(IDimensionLibrary.class, DimensionLibrary.class)
.registerSingleton(IDimensionInformation.class, DimensionInformation.class)
.registerFactory(ISeasonalInformation.class, () -> SeasonManager.HANDLER)
.registerSingleton(IBlockLibrary.class, BlockLibrary.class)
.registerSingleton(IItemLibrary.class, ItemLibrary.class)
.registerSingleton(IEntityEffectLibrary.class, EntityEffectLibrary.class)
Expand Down Expand Up @@ -180,11 +183,6 @@ public void onComplete(Minecraft client) {
// of the dependencies to be initialized.
container.resolve(Handlers.class);

// Make sure our particle sheets get registered otherwise they will not render.
// These sheets are purely client side - they have to be manhandled into the
// Minecraft environment.
ParticleSheets.register();

this.logger.info("[%s] Finalization complete", Constants.MOD_ID);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ public static class SoundOptions {
@Property
@Comment("Enables display of toast messages for credited music")
public boolean displayToastMessagesForMusic = true;

@Property
@Comment("Enables sound remapping when sounds are played")
public boolean remapSounds = true;
}

public static class BlockEffects {
Expand Down Expand Up @@ -232,6 +236,11 @@ public static class EntityEffects {
@Comment("Enable/disable player toolbar sound effects")
public boolean enablePlayerToolbarEffect = true;

@Property
@RestartRequired(client = false)
@Comment("Enable/disable sound effects for blocks on the toolbar")
public boolean enableToolbarBlockSounds = false;

@Property
@RestartRequired(client = false)
@Comment("Enable/disable item swing sound effects from players and mobs")
Expand Down Expand Up @@ -259,10 +268,6 @@ public static class FootstepAccents {
@Property
@Comment("Enable/disable accents when the player is walking on squeaky blocks")
public boolean enableFloorSqueaks = true;

@Property
@Comment("Enable/disable accents for when the player is walking on leafy blocks")
public boolean enableLeafAccents = true;
}

public static class ParticleTweaks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ public class MusicManagerCommand extends AbstractClientCommand {
private static final String RESET = "reset";
private static final String PAUSE = "pause";
private static final String UNPAUSE = "unpause";
private static final String WHATS_PLAYING = "whatsplaying";

@Override
public void register(CommandDispatcher<ClientCommandRegistrationEvent.ClientCommandSourceStack> dispatcher, CommandBuildContext registryAccess) {
dispatcher.register(ClientCommandRegistrationEvent.literal(COMMAND)
.then(subCommand(RESET, MusicManagerCommandHandler::reset))
.then(subCommand(PAUSE, MusicManagerCommandHandler::pause))
.then(subCommand(UNPAUSE, MusicManagerCommandHandler::unpause)));
.then(subCommand(UNPAUSE, MusicManagerCommandHandler::unpause))
.then(subCommand(WHATS_PLAYING, MusicManagerCommandHandler::whatsPlaying)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.network.chat.Component;
import org.orecruncher.dsurround.lib.GameUtils;
import org.orecruncher.dsurround.lib.config.ConfigurationData;
import org.orecruncher.dsurround.mixinutils.IMusicManager;

public class MusicManagerCommandHandler {
Expand Down Expand Up @@ -32,4 +33,13 @@ public static Component pause() {
return Component.translatable("dsurround.command.dsmm.pause.failure", t.getMessage());
}
}

public static Component whatsPlaying() {
try {
var result = ((IMusicManager)(GameUtils.getMC().getMusicManager())).dsurround_whatsPlaying();
return Component.translatable("dsurround.command.dsmm.whatsplaying.success", result);
} catch (Throwable t) {
return Component.translatable("dsurround.command.dsmm.whatsplaying.failure", t.getMessage());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.orecruncher.dsurround.config;

import com.google.common.base.MoreObjects;
import net.minecraft.util.random.Weight;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.orecruncher.dsurround.lib.WeightTable;
import org.orecruncher.dsurround.lib.di.ContainerManager;
Expand All @@ -11,29 +13,30 @@
public class AcousticEntry implements WeightTable.IItem<ISoundFactory> {

private static final IConditionEvaluator CONDITION_EVALUATOR = ContainerManager.resolve(IConditionEvaluator.class);
private static final int DEFAULT_WEIGHT = 10;
private static final Weight DEFAULT_WEIGHT = Weight.of(10);

private final int weight;
private final Weight weight;
private final ISoundFactory acoustic;
private final Script conditions;

public AcousticEntry(final ISoundFactory acoustic, @Nullable final Script condition) {
this(acoustic, condition, DEFAULT_WEIGHT);
}

public AcousticEntry(final ISoundFactory acoustic, @Nullable final Script condition, int weight) {
public AcousticEntry(final ISoundFactory acoustic, @Nullable final Script condition, Weight weight) {
this.acoustic = acoustic;
this.weight = weight;
this.conditions = condition != null ? condition : Script.TRUE;
}

@NotNull
@Override
public int getWeight() {
public Weight getWeight() {
return this.weight;
}

@Override
public ISoundFactory getItem() {
public ISoundFactory data() {
return getAcoustic();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,71 @@
package org.orecruncher.dsurround.config;

import net.minecraft.util.random.SimpleWeightedRandomList;
import org.orecruncher.dsurround.lib.WeightTable;
import org.orecruncher.dsurround.lib.collections.ObjectArray;
import org.orecruncher.dsurround.lib.random.Randomizer;
import org.orecruncher.dsurround.sound.ISoundFactory;

import java.util.Optional;
import java.util.stream.Stream;

@SuppressWarnings("unused")
public class AcousticEntryCollection extends ObjectArray<AcousticEntry> {

public static final AcousticEntryCollection EMPTY;

static {
EMPTY = new AcousticEntryCollection() {
@Override
public boolean add(AcousticEntry entry) {
throw new RuntimeException("Cannot add AcousticEntry to EMPTY collection");
}
@Override
public Stream<AcousticEntry> findMatches() {
return Stream.empty();
}
@Override
public Optional<ISoundFactory> makeSelection() {
return Optional.empty();
}
@Override
public SimpleWeightedRandomList<ISoundFactory> matchesAsWeightedList() {
return SimpleWeightedRandomList.empty();
}
};
EMPTY.trim();
}

@Override
public boolean add(AcousticEntry entry) {
if (this.contains(entry))
return false;

return super.add(entry);
}

/**
* Stream of AcousticEntries that match the current conditions within
* the game.
*/
public Stream<AcousticEntry> findMatches() {
return this.stream().filter(AcousticEntry::matches);
}

/**
* Creates a SimpleWeightedRandomList based on valid candidates from within
* the collection.
*/
public SimpleWeightedRandomList<ISoundFactory> matchesAsWeightedList() {
var builder = new SimpleWeightedRandomList.Builder<ISoundFactory>();
this.findMatches().forEach(m -> builder.add(m.getAcoustic(), m.getWeight().asInt()));
return builder.build();
}

/**
* Makes a weighted choice from the candidates available in the
* collection.
*/
public Optional<ISoundFactory> makeSelection() {
return WeightTable.makeSelection(this.findMatches(), Randomizer.current());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.orecruncher.dsurround.config.dimension;
package org.orecruncher.dsurround.config;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
Expand All @@ -19,6 +19,7 @@ public class DimensionInfo {
protected int spaceHeight;
protected boolean alwaysOutside = false;
protected boolean playBiomeSounds = true;
protected boolean compassWobble = false;

DimensionInfo() {
this.name = ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, "no_dimension");
Expand All @@ -37,6 +38,8 @@ public DimensionInfo(final Level world) {
// Force sea level based on known world types that give heartburn
if (this.isFlatWorld)
this.seaLevel = 0;

this.compassWobble = !world.dimensionType().natural();
}

public void update(DimensionConfigRule config) {
Expand All @@ -49,6 +52,8 @@ public void update(DimensionConfigRule config) {
v -> this.cloudHeight = v,
() -> this.cloudHeight = this.skyHeight / 2);

config.compassWobble().ifPresent(v -> this.compassWobble = v);

this.spaceHeight = this.skyHeight + SPACE_HEIGHT_OFFSET;
}
}
Expand Down Expand Up @@ -85,4 +90,8 @@ public boolean isFlatWorld() {
return this.isFlatWorld;
}

public boolean getCompassWobble() {
return this.compassWobble;
}

}
Loading

0 comments on commit 0d352c7

Please sign in to comment.