From 129be61fee13e15e17c2e2a4ee0b08c9bc004846 Mon Sep 17 00:00:00 2001 From: Rabbitminers Date: Mon, 3 Apr 2023 17:20:17 +0100 Subject: [PATCH] Fixed Bogey Sound Loading --- .../content/logistics/trains/entity/BogeyStyle.java | 12 +++++++++++- .../logistics/trains/entity/CarriageSounds.java | 2 +- .../create/foundation/data/BogeyStyleBuilder.java | 6 +++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/BogeyStyle.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/BogeyStyle.java index bd75ec0d9..ddc1d25db 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/BogeyStyle.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/BogeyStyle.java @@ -1,6 +1,7 @@ package com.simibubi.create.content.logistics.trains.entity; import com.jozufozu.flywheel.api.MaterialManager; +import com.simibubi.create.AllSoundEvents; import com.simibubi.create.content.logistics.trains.BogeyRenderer; import com.simibubi.create.content.logistics.trains.BogeyRenderer.BogeySize; import com.simibubi.create.content.logistics.trains.AbstractBogeyBlock; @@ -15,6 +16,8 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistryEntry; import net.minecraftforge.registries.IForgeRegistryEntry; +import org.jetbrains.annotations.NotNull; + import java.util.EnumMap; import java.util.Map; import java.util.Set; @@ -24,7 +27,7 @@ import java.util.stream.Stream; public final class BogeyStyle extends ForgeRegistryEntry implements IForgeRegistryEntry { public Map blocks = new EnumMap<>(BogeySize.class); public Component displayName; - public SoundEvent soundType; + public ResourceLocation soundType; public CompoundTag defaultData; public BogeyRenderer renderer; @@ -58,6 +61,13 @@ public final class BogeyStyle extends ForgeRegistryEntry implements return sizes[nextOrdinal]; } + @NotNull + public SoundEvent getSoundType() { + AllSoundEvents.SoundEntry entry = AllSoundEvents.ALL.get(this.soundType); + if (entry == null) entry = AllSoundEvents.TRAIN2; + return entry.getMainEvent(); + } + public BogeyInstance createInstance(CarriageBogey bogey, BogeySize size, MaterialManager materialManager) { return new BogeyInstance(bogey, this.renderer.newInstance(), size, materialManager); } diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageSounds.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageSounds.java index 097ffe5bf..28778e196 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageSounds.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageSounds.java @@ -86,7 +86,7 @@ public class CarriageSounds { CarriageContraptionEntity cce = dce.entity.get(); if (cce != null) { Couple bogeys = cce.getCarriage().bogeys; - closestBogeySound = bogeys.get(distance1 > distance2).getStyle().soundType; + closestBogeySound = bogeys.get(distance1 > distance2).getStyle().getSoundType(); } Vec3 toCarriage = distance1 > distance2 ? toBogey2 : toBogey1; diff --git a/src/main/java/com/simibubi/create/foundation/data/BogeyStyleBuilder.java b/src/main/java/com/simibubi/create/foundation/data/BogeyStyleBuilder.java index 253b8fa89..72ebc0b90 100644 --- a/src/main/java/com/simibubi/create/foundation/data/BogeyStyleBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/data/BogeyStyleBuilder.java @@ -36,7 +36,7 @@ import java.util.function.Supplier; public class BogeyStyleBuilder extends AbstractBuilder> { private final T style; private NonNullSupplier renderer; - private Supplier soundType; + private Supplier soundType; private Supplier data; private Supplier> particles; @@ -47,7 +47,7 @@ public class BogeyStyleBuilder extends AbstractBuilder< protected BogeyStyleBuilder(AbstractRegistrate owner, P parent, String name, BuilderCallback callback, T style) { super(owner, parent, name, callback, AllRegistries.Keys.BOGEYS); this.style = style; - this.soundType = AllSoundEvents.TRAIN2::getMainEvent; + this.soundType = AllSoundEvents.TRAIN2::getId; this.particles = AllParticleTypes.AIR_FLOW::get; this.data = CompoundTag::new; } @@ -62,7 +62,7 @@ public class BogeyStyleBuilder extends AbstractBuilder< return this; } - public BogeyStyleBuilder soundType(SoundEvent soundEntry) { + public BogeyStyleBuilder soundType(ResourceLocation soundEntry) { this.soundType = () -> soundEntry; return this; }