Fixed Default Values When Used Styles Are Removed

This commit is contained in:
Rabbitminers 2023-04-03 21:30:28 +01:00
parent 4f176979de
commit 69326e361a
3 changed files with 21 additions and 3 deletions

View file

@ -20,6 +20,21 @@ public class AllBogeyStyles {
.renderer(new StandardBogeyRenderer())
.register();
/*
public static final RegistryEntry<BogeyStyle> TEST = REGISTRATE
.bogeyStyle("test", new BogeyStyle())
.block(BogeySizes.LARGE, AllBlocks.LARGE_BOGEY)
.renderer(new TestBogeyRenderer())
.register();
public static final RegistryEntry<BogeyStyle> TEST_TWO = REGISTRATE
.bogeyStyle("test_two", new BogeyStyle())
.block(BogeySizes.SMALL, AllBlocks.SMALL_BOGEY)
.renderer(new TestBogeyRenderer())
.register();
*/
public static void register() {
LOGGER.info("Registered bogey styles from " + Create.ID);
AllRegistries.DEFERRED_BOGEY_REGISTRY.register(FMLJavaModLoadingContext.get().getModEventBus());

View file

@ -4,7 +4,6 @@ import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.AllSoundEvents.SoundEntry;
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.Chaser;
@ -43,7 +42,8 @@ public class CarriageSounds {
this.entity = entity;
bogeySounds = entity.getCarriage().bogeys.map(bogey ->
bogey != null ? bogey.getStyle().getSoundType()
: AllSoundEvents.TRAIN2.getMainEvent());
: AllSoundEvents.TRAIN2.getMainEvent());
closestBogeySound = bogeySounds.getFirst();
distanceFactor = LerpedFloat.linear();
speedFactor = LerpedFloat.linear();
approachFactor = LerpedFloat.linear();

View file

@ -56,7 +56,10 @@ public class StandardBogeyTileEntity extends CachedRenderBBTileEntity {
CompoundTag data = this.getBogeyData();
ResourceLocation currentStyle = NBTHelper.readResourceLocation(data, BOGEY_STYLE_KEY);
BogeyStyle style = AllRegistries.BOGEY_REGISTRY.get().getValue(currentStyle);
if (style == null) setBogeyStyle(AllBogeyStyles.STANDARD.get());
if (style == null) {
setBogeyStyle(AllBogeyStyles.STANDARD.get());
return getStyle();
}
return style;
}