mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-12 07:16:54 +01:00
Fixed Bogey Sound Loading
This commit is contained in:
parent
2543185a55
commit
129be61fee
3 changed files with 15 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
||||||
package com.simibubi.create.content.logistics.trains.entity;
|
package com.simibubi.create.content.logistics.trains.entity;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.api.MaterialManager;
|
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;
|
||||||
import com.simibubi.create.content.logistics.trains.BogeyRenderer.BogeySize;
|
import com.simibubi.create.content.logistics.trains.BogeyRenderer.BogeySize;
|
||||||
import com.simibubi.create.content.logistics.trains.AbstractBogeyBlock;
|
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.ForgeRegistryEntry;
|
||||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -24,7 +27,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 SoundEvent soundType;
|
public ResourceLocation soundType;
|
||||||
public CompoundTag defaultData;
|
public CompoundTag defaultData;
|
||||||
public BogeyRenderer renderer;
|
public BogeyRenderer renderer;
|
||||||
|
|
||||||
|
@ -58,6 +61,13 @@ public final class BogeyStyle extends ForgeRegistryEntry<BogeyStyle> implements
|
||||||
return sizes[nextOrdinal];
|
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) {
|
public BogeyInstance createInstance(CarriageBogey bogey, BogeySize size, MaterialManager materialManager) {
|
||||||
return new BogeyInstance(bogey, this.renderer.newInstance(), size, materialManager);
|
return new BogeyInstance(bogey, this.renderer.newInstance(), size, materialManager);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class CarriageSounds {
|
||||||
CarriageContraptionEntity cce = dce.entity.get();
|
CarriageContraptionEntity cce = dce.entity.get();
|
||||||
if (cce != null) {
|
if (cce != null) {
|
||||||
Couple<CarriageBogey> bogeys = cce.getCarriage().bogeys;
|
Couple<CarriageBogey> bogeys = cce.getCarriage().bogeys;
|
||||||
closestBogeySound = bogeys.get(distance1 > distance2).getStyle().soundType;
|
closestBogeySound = bogeys.get(distance1 > distance2).getStyle().getSoundType();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3 toCarriage = distance1 > distance2 ? toBogey2 : toBogey1;
|
Vec3 toCarriage = distance1 > distance2 ? toBogey2 : toBogey1;
|
||||||
|
|
|
@ -36,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<SoundEvent> soundType;
|
private Supplier<ResourceLocation> soundType;
|
||||||
private Supplier<CompoundTag> data;
|
private Supplier<CompoundTag> data;
|
||||||
private Supplier<ParticleType<?>> particles;
|
private Supplier<ParticleType<?>> particles;
|
||||||
|
|
||||||
|
@ -47,7 +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.soundType = AllSoundEvents.TRAIN2::getId;
|
||||||
this.particles = AllParticleTypes.AIR_FLOW::get;
|
this.particles = AllParticleTypes.AIR_FLOW::get;
|
||||||
this.data = CompoundTag::new;
|
this.data = CompoundTag::new;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class BogeyStyleBuilder<T extends BogeyStyle, P> extends AbstractBuilder<
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BogeyStyleBuilder<T, P> soundType(SoundEvent soundEntry) {
|
public BogeyStyleBuilder<T, P> soundType(ResourceLocation soundEntry) {
|
||||||
this.soundType = () -> soundEntry;
|
this.soundType = () -> soundEntry;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue