mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-26 18:39:20 +00:00
改进totem指令
This commit is contained in:
@@ -172,6 +172,7 @@ public abstract class CraftEngine implements Plugin {
|
||||
// collect illegal characters from minecraft:default font
|
||||
this.fontManager.delayedLoad();
|
||||
this.advancementManager.delayedLoad();
|
||||
this.soundManager.delayedLoad();
|
||||
if (reloadRecipe) {
|
||||
// convert data pack recipes
|
||||
this.recipeManager.delayedLoad();
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.momirealms.craftengine.core.plugin.config.ConfigParser;
|
||||
import net.momirealms.craftengine.core.plugin.config.IdSectionConfigParser;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.*;
|
||||
import org.incendo.cloud.suggestion.Suggestion;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
@@ -21,6 +22,7 @@ public abstract class AbstractSoundManager implements SoundManager {
|
||||
protected final SoundParser soundParser;
|
||||
protected final SongParser songParser;
|
||||
protected final Map<Integer, Key> customSoundsInRegistry = new HashMap<>();
|
||||
protected final List<Suggestion> soundSuggestions = new ArrayList<>();
|
||||
|
||||
public AbstractSoundManager(CraftEngine plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -43,6 +45,22 @@ public abstract class AbstractSoundManager implements SoundManager {
|
||||
this.byId.clear();
|
||||
this.byNamespace.clear();
|
||||
this.songs.clear();
|
||||
this.soundSuggestions.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delayedLoad() {
|
||||
for (Key key : VANILLA_SOUND_EVENTS) {
|
||||
this.soundSuggestions.add(Suggestion.suggestion(key.asString()));
|
||||
}
|
||||
for (Key key : this.byId.keySet()) {
|
||||
this.soundSuggestions.add(Suggestion.suggestion(key.asString()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Suggestion> cachedSoundSuggestions() {
|
||||
return this.soundSuggestions;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -57,6 +57,11 @@ public record SoundData(Key id, SoundValue volume, SoundValue pitch) {
|
||||
}
|
||||
|
||||
static SoundValue ranged(float min, float max) {
|
||||
if (min > max) {
|
||||
return new Ranged(max, min);
|
||||
} else if (min == max) {
|
||||
return SoundValue.fixed(max);
|
||||
}
|
||||
return new Ranged(min, max);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@ package net.momirealms.craftengine.core.sound;
|
||||
import net.momirealms.craftengine.core.plugin.Manageable;
|
||||
import net.momirealms.craftengine.core.plugin.config.ConfigParser;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import org.incendo.cloud.suggestion.Suggestion;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface SoundManager extends Manageable {
|
||||
@@ -12,5 +14,7 @@ public interface SoundManager extends Manageable {
|
||||
|
||||
ConfigParser[] parsers();
|
||||
|
||||
List<Suggestion> cachedSoundSuggestions();
|
||||
|
||||
Map<Key, SoundEvent> sounds();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user