-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [#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
1 parent
4fbe3fa
commit 0d352c7
Showing
239 changed files
with
1,914 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 58 additions & 1 deletion
59
common/src/main/java/org/orecruncher/dsurround/config/AcousticEntryCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.