trurwsuieghfdskg
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package net.minecraft.sounds;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Holder;
|
||||
|
||||
public class Music {
|
||||
public static final Codec<Music> CODEC = RecordCodecBuilder.create((p_11635_) -> {
|
||||
return p_11635_.group(SoundEvent.CODEC.fieldOf("sound").forGetter((p_144041_) -> {
|
||||
return p_144041_.event;
|
||||
}), Codec.INT.fieldOf("min_delay").forGetter((p_144039_) -> {
|
||||
return p_144039_.minDelay;
|
||||
}), Codec.INT.fieldOf("max_delay").forGetter((p_144037_) -> {
|
||||
return p_144037_.maxDelay;
|
||||
}), Codec.BOOL.fieldOf("replace_current_music").forGetter((p_144035_) -> {
|
||||
return p_144035_.replaceCurrentMusic;
|
||||
})).apply(p_11635_, Music::new);
|
||||
});
|
||||
private final Holder<SoundEvent> event;
|
||||
private final int minDelay;
|
||||
private final int maxDelay;
|
||||
private final boolean replaceCurrentMusic;
|
||||
|
||||
public Music(Holder<SoundEvent> p_263426_, int p_263377_, int p_263383_, boolean p_263387_) {
|
||||
this.event = p_263426_;
|
||||
this.minDelay = p_263377_;
|
||||
this.maxDelay = p_263383_;
|
||||
this.replaceCurrentMusic = p_263387_;
|
||||
}
|
||||
|
||||
public Holder<SoundEvent> getEvent() {
|
||||
return this.event;
|
||||
}
|
||||
|
||||
public int getMinDelay() {
|
||||
return this.minDelay;
|
||||
}
|
||||
|
||||
public int getMaxDelay() {
|
||||
return this.maxDelay;
|
||||
}
|
||||
|
||||
public boolean replaceCurrentMusic() {
|
||||
return this.replaceCurrentMusic;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.minecraft.sounds;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
|
||||
public class Musics {
|
||||
private static final int ONE_SECOND = 20;
|
||||
private static final int THIRTY_SECONDS = 600;
|
||||
private static final int TEN_MINUTES = 12000;
|
||||
private static final int TWENTY_MINUTES = 24000;
|
||||
private static final int FIVE_MINUTES = 6000;
|
||||
public static final Music MENU = new Music(SoundEvents.MUSIC_MENU, 20, 600, true);
|
||||
public static final Music CREATIVE = new Music(SoundEvents.MUSIC_CREATIVE, 12000, 24000, false);
|
||||
public static final Music CREDITS = new Music(SoundEvents.MUSIC_CREDITS, 0, 0, true);
|
||||
public static final Music END_BOSS = new Music(SoundEvents.MUSIC_DRAGON, 0, 0, true);
|
||||
public static final Music END = new Music(SoundEvents.MUSIC_END, 6000, 24000, true);
|
||||
public static final Music UNDER_WATER = createGameMusic(SoundEvents.MUSIC_UNDER_WATER);
|
||||
public static final Music GAME = createGameMusic(SoundEvents.MUSIC_GAME);
|
||||
|
||||
public static Music createGameMusic(Holder<SoundEvent> p_263395_) {
|
||||
return new Music(p_263395_, 12000, 24000, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package net.minecraft.sounds;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import java.util.Optional;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.RegistryFileCodec;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class SoundEvent {
|
||||
public static final Codec<SoundEvent> DIRECT_CODEC = RecordCodecBuilder.create((p_263380_) -> {
|
||||
return p_263380_.group(ResourceLocation.CODEC.fieldOf("sound_id").forGetter(SoundEvent::getLocation), Codec.FLOAT.optionalFieldOf("range").forGetter(SoundEvent::fixedRange)).apply(p_263380_, SoundEvent::create);
|
||||
});
|
||||
public static final Codec<Holder<SoundEvent>> CODEC = RegistryFileCodec.create(Registries.SOUND_EVENT, DIRECT_CODEC);
|
||||
private static final float DEFAULT_RANGE = 16.0F;
|
||||
private final ResourceLocation location;
|
||||
private final float range;
|
||||
private final boolean newSystem;
|
||||
|
||||
private static SoundEvent create(ResourceLocation p_263406_, Optional<Float> p_263346_) {
|
||||
return p_263346_.map((p_263360_) -> {
|
||||
return createFixedRangeEvent(p_263406_, p_263360_);
|
||||
}).orElseGet(() -> {
|
||||
return createVariableRangeEvent(p_263406_);
|
||||
});
|
||||
}
|
||||
|
||||
public static SoundEvent createVariableRangeEvent(ResourceLocation p_262973_) {
|
||||
return new SoundEvent(p_262973_, 16.0F, false);
|
||||
}
|
||||
|
||||
public static SoundEvent createFixedRangeEvent(ResourceLocation p_263003_, float p_263029_) {
|
||||
return new SoundEvent(p_263003_, p_263029_, true);
|
||||
}
|
||||
|
||||
private SoundEvent(ResourceLocation p_215665_, float p_215666_, boolean p_215667_) {
|
||||
this.location = p_215665_;
|
||||
this.range = p_215666_;
|
||||
this.newSystem = p_215667_;
|
||||
}
|
||||
|
||||
public ResourceLocation getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
public float getRange(float p_215669_) {
|
||||
if (this.newSystem) {
|
||||
return this.range;
|
||||
} else {
|
||||
return p_215669_ > 1.0F ? 16.0F * p_215669_ : 16.0F;
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<Float> fixedRange() {
|
||||
return this.newSystem ? Optional.of(this.range) : Optional.empty();
|
||||
}
|
||||
|
||||
public void writeToNetwork(FriendlyByteBuf p_263344_) {
|
||||
p_263344_.writeResourceLocation(this.location);
|
||||
p_263344_.writeOptional(this.fixedRange(), FriendlyByteBuf::writeFloat);
|
||||
}
|
||||
|
||||
public static SoundEvent readFromNetwork(FriendlyByteBuf p_263371_) {
|
||||
ResourceLocation resourcelocation = p_263371_.readResourceLocation();
|
||||
Optional<Float> optional = p_263371_.readOptional(FriendlyByteBuf::readFloat);
|
||||
return create(resourcelocation, optional);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
package net.minecraft.sounds;
|
||||
|
||||
public enum SoundSource {
|
||||
MASTER("master"),
|
||||
MUSIC("music"),
|
||||
RECORDS("record"),
|
||||
WEATHER("weather"),
|
||||
BLOCKS("block"),
|
||||
HOSTILE("hostile"),
|
||||
NEUTRAL("neutral"),
|
||||
PLAYERS("player"),
|
||||
AMBIENT("ambient"),
|
||||
VOICE("voice");
|
||||
|
||||
private final String name;
|
||||
|
||||
private SoundSource(String p_12675_) {
|
||||
this.name = p_12675_;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
package net.minecraft.sounds;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import net.minecraft.FieldsAreNonnullByDefault;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
Reference in New Issue
Block a user