mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-26 15:06:42 +01:00
Added Bogey Sound Customisation
This commit is contained in:
parent
1ad5ae9514
commit
2543185a55
3 changed files with 20 additions and 5 deletions
|
@ -8,6 +8,7 @@ import com.simibubi.create.content.logistics.trains.AbstractBogeyBlock;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
@ -23,7 +24,7 @@ import java.util.stream.Stream;
|
||||||
public final class BogeyStyle extends ForgeRegistryEntry<BogeyStyle> implements IForgeRegistryEntry<BogeyStyle> {
|
public final class BogeyStyle extends ForgeRegistryEntry<BogeyStyle> implements IForgeRegistryEntry<BogeyStyle> {
|
||||||
public Map<BogeySize, ResourceLocation> blocks = new EnumMap<>(BogeySize.class);
|
public Map<BogeySize, ResourceLocation> blocks = new EnumMap<>(BogeySize.class);
|
||||||
public Component displayName;
|
public Component displayName;
|
||||||
public SoundType soundType;
|
public SoundEvent soundType;
|
||||||
public CompoundTag defaultData;
|
public CompoundTag defaultData;
|
||||||
public BogeyRenderer renderer;
|
public BogeyRenderer renderer;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.simibubi.create.content.logistics.trains.entity;
|
||||||
import com.simibubi.create.AllSoundEvents;
|
import com.simibubi.create.AllSoundEvents;
|
||||||
import com.simibubi.create.AllSoundEvents.SoundEntry;
|
import com.simibubi.create.AllSoundEvents.SoundEntry;
|
||||||
import com.simibubi.create.content.logistics.trains.entity.Carriage.DimensionalCarriageEntity;
|
import com.simibubi.create.content.logistics.trains.entity.Carriage.DimensionalCarriageEntity;
|
||||||
|
import com.simibubi.create.foundation.utility.Couple;
|
||||||
|
import com.simibubi.create.foundation.utility.Pair;
|
||||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
|
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
|
||||||
|
|
||||||
|
@ -29,6 +31,8 @@ public class CarriageSounds {
|
||||||
LoopingSound sharedWheelSoundSeated;
|
LoopingSound sharedWheelSoundSeated;
|
||||||
LoopingSound sharedHonkSound;
|
LoopingSound sharedHonkSound;
|
||||||
|
|
||||||
|
SoundEvent closestBogeySound;
|
||||||
|
|
||||||
boolean arrived;
|
boolean arrived;
|
||||||
|
|
||||||
int tick;
|
int tick;
|
||||||
|
@ -79,6 +83,12 @@ public class CarriageSounds {
|
||||||
double distance1 = toBogey1.length();
|
double distance1 = toBogey1.length();
|
||||||
double distance2 = toBogey2.length();
|
double distance2 = toBogey2.length();
|
||||||
|
|
||||||
|
CarriageContraptionEntity cce = dce.entity.get();
|
||||||
|
if (cce != null) {
|
||||||
|
Couple<CarriageBogey> bogeys = cce.getCarriage().bogeys;
|
||||||
|
closestBogeySound = bogeys.get(distance1 > distance2).getStyle().soundType;
|
||||||
|
}
|
||||||
|
|
||||||
Vec3 toCarriage = distance1 > distance2 ? toBogey2 : toBogey1;
|
Vec3 toCarriage = distance1 > distance2 ? toBogey2 : toBogey1;
|
||||||
double distance = Math.min(distance1, distance2);
|
double distance = Math.min(distance1, distance2);
|
||||||
Vec3 soundLocation = cam.add(toCarriage);
|
Vec3 soundLocation = cam.add(toCarriage);
|
||||||
|
@ -97,7 +107,7 @@ public class CarriageSounds {
|
||||||
seatCrossfade.tickChaser();
|
seatCrossfade.tickChaser();
|
||||||
|
|
||||||
minecartEsqueSound = playIfMissing(mc, minecartEsqueSound, AllSoundEvents.TRAIN.getMainEvent());
|
minecartEsqueSound = playIfMissing(mc, minecartEsqueSound, AllSoundEvents.TRAIN.getMainEvent());
|
||||||
sharedWheelSound = playIfMissing(mc, sharedWheelSound, AllSoundEvents.TRAIN2.getMainEvent());
|
sharedWheelSound = playIfMissing(mc, sharedWheelSound, closestBogeySound);
|
||||||
sharedWheelSoundSeated = playIfMissing(mc, sharedWheelSoundSeated, AllSoundEvents.TRAIN3.getMainEvent());
|
sharedWheelSoundSeated = playIfMissing(mc, sharedWheelSoundSeated, AllSoundEvents.TRAIN3.getMainEvent());
|
||||||
|
|
||||||
float volume = Math.min(Math.min(speedFactor.getValue(), distanceFactor.getValue() / 100),
|
float volume = Math.min(Math.min(speedFactor.getValue(), distanceFactor.getValue() / 100),
|
||||||
|
@ -205,7 +215,7 @@ public class CarriageSounds {
|
||||||
public void submitSharedSoundVolume(Vec3 location, float volume) {
|
public void submitSharedSoundVolume(Vec3 location, float volume) {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
minecartEsqueSound = playIfMissing(mc, minecartEsqueSound, AllSoundEvents.TRAIN.getMainEvent());
|
minecartEsqueSound = playIfMissing(mc, minecartEsqueSound, AllSoundEvents.TRAIN.getMainEvent());
|
||||||
sharedWheelSound = playIfMissing(mc, sharedWheelSound, AllSoundEvents.TRAIN2.getMainEvent());
|
sharedWheelSound = playIfMissing(mc, sharedWheelSound, closestBogeySound);
|
||||||
sharedWheelSoundSeated = playIfMissing(mc, sharedWheelSoundSeated, AllSoundEvents.TRAIN3.getMainEvent());
|
sharedWheelSoundSeated = playIfMissing(mc, sharedWheelSoundSeated, AllSoundEvents.TRAIN3.getMainEvent());
|
||||||
|
|
||||||
boolean approach = true;
|
boolean approach = true;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import net.minecraft.core.particles.ParticleType;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.level.block.SoundType;
|
import net.minecraft.world.level.block.SoundType;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -35,7 +36,7 @@ import java.util.function.Supplier;
|
||||||
public class BogeyStyleBuilder<T extends BogeyStyle, P> extends AbstractBuilder<BogeyStyle, T, P, BogeyStyleBuilder<T, P>> {
|
public class BogeyStyleBuilder<T extends BogeyStyle, P> extends AbstractBuilder<BogeyStyle, T, P, BogeyStyleBuilder<T, P>> {
|
||||||
private final T style;
|
private final T style;
|
||||||
private NonNullSupplier<BogeyRenderer> renderer;
|
private NonNullSupplier<BogeyRenderer> renderer;
|
||||||
private Supplier<AllSoundEvents.SoundEntry> soundType;
|
private Supplier<SoundEvent> soundType;
|
||||||
private Supplier<CompoundTag> data;
|
private Supplier<CompoundTag> data;
|
||||||
private Supplier<ParticleType<?>> particles;
|
private Supplier<ParticleType<?>> particles;
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ public class BogeyStyleBuilder<T extends BogeyStyle, P> extends AbstractBuilder<
|
||||||
protected BogeyStyleBuilder(AbstractRegistrate<?> owner, P parent, String name, BuilderCallback callback, T style) {
|
protected BogeyStyleBuilder(AbstractRegistrate<?> owner, P parent, String name, BuilderCallback callback, T style) {
|
||||||
super(owner, parent, name, callback, AllRegistries.Keys.BOGEYS);
|
super(owner, parent, name, callback, AllRegistries.Keys.BOGEYS);
|
||||||
this.style = style;
|
this.style = style;
|
||||||
|
this.soundType = AllSoundEvents.TRAIN2::getMainEvent;
|
||||||
this.particles = AllParticleTypes.AIR_FLOW::get;
|
this.particles = AllParticleTypes.AIR_FLOW::get;
|
||||||
this.data = CompoundTag::new;
|
this.data = CompoundTag::new;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +62,8 @@ public class BogeyStyleBuilder<T extends BogeyStyle, P> extends AbstractBuilder<
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BogeyStyleBuilder<T, P> soundType(SoundType soundEntry) {
|
public BogeyStyleBuilder<T, P> soundType(SoundEvent soundEntry) {
|
||||||
|
this.soundType = () -> soundEntry;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +85,7 @@ public class BogeyStyleBuilder<T extends BogeyStyle, P> extends AbstractBuilder<
|
||||||
protected @NotNull T createEntry() {
|
protected @NotNull T createEntry() {
|
||||||
style.defaultData = data.get();
|
style.defaultData = data.get();
|
||||||
style.renderer = renderer.get();
|
style.renderer = renderer.get();
|
||||||
|
style.soundType = soundType.get();
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue