Cleanup dynamic sounds patch, bump eviction time to 5 minutes

This commit is contained in:
embeddedt 2023-10-07 18:44:33 -04:00
parent 803aaba204
commit bf6979e45b
2 changed files with 7 additions and 8 deletions

View File

@ -24,13 +24,12 @@ public abstract class SoundBufferLibraryMixin {
private static final boolean debugDynamicSoundLoading = Boolean.getBoolean("modernfix.debugDynamicSoundLoading"); private static final boolean debugDynamicSoundLoading = Boolean.getBoolean("modernfix.debugDynamicSoundLoading");
@Shadow @Final @Mutable @Shadow @Final @Mutable
private Map<ResourceLocation, CompletableFuture<SoundBuffer>> cache = private Map<ResourceLocation, CompletableFuture<SoundBuffer>> cache = CacheBuilder.newBuilder()
CacheBuilder.newBuilder() .expireAfterAccess(DynamicSoundHelpers.MAX_SOUND_LIFETIME_SECS, TimeUnit.SECONDS)
.expireAfterAccess(DynamicSoundHelpers.MAX_SOUND_LIFETIME_SECS, TimeUnit.SECONDS) // Excessive use of type hinting due to it assuming Object as the broadest correct type
// Excessive use of type hinting due to it assuming Object as the broadest correct type .<ResourceLocation, CompletableFuture<SoundBuffer>>removalListener(this::onSoundRemoval)
.<ResourceLocation, CompletableFuture<SoundBuffer>>removalListener(this::onSoundRemoval) .build()
.<ResourceLocation, CompletableFuture<SoundBuffer>>build() .asMap();
.asMap();
private <K extends ResourceLocation, V extends CompletableFuture<SoundBuffer>> void onSoundRemoval(RemovalNotification<K, V> notification) { private <K extends ResourceLocation, V extends CompletableFuture<SoundBuffer>> void onSoundRemoval(RemovalNotification<K, V> notification) {
notification.getValue().thenAccept(SoundBuffer::discardAlBuffer); notification.getValue().thenAccept(SoundBuffer::discardAlBuffer);

View File

@ -4,5 +4,5 @@ public class DynamicSoundHelpers {
/** /**
* The duration until a sound is eligible for eviction if unused. * The duration until a sound is eligible for eviction if unused.
*/ */
public static final int MAX_SOUND_LIFETIME_SECS = 120; public static final int MAX_SOUND_LIFETIME_SECS = 300;
} }