From f60aea579682ad27f58626824545c5541b62eb75 Mon Sep 17 00:00:00 2001 From: IThundxr Date: Sat, 26 Oct 2024 10:17:17 -0400 Subject: [PATCH] fix potential crash --- ...rriage$DimensionalCarriageEntityMixin.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/dev/ithundxr/railwaystweaks/mixin/compat/create/Carriage$DimensionalCarriageEntityMixin.java b/src/main/java/dev/ithundxr/railwaystweaks/mixin/compat/create/Carriage$DimensionalCarriageEntityMixin.java index eb270e1..5bb9842 100644 --- a/src/main/java/dev/ithundxr/railwaystweaks/mixin/compat/create/Carriage$DimensionalCarriageEntityMixin.java +++ b/src/main/java/dev/ithundxr/railwaystweaks/mixin/compat/create/Carriage$DimensionalCarriageEntityMixin.java @@ -25,19 +25,21 @@ public class Carriage$DimensionalCarriageEntityMixin { @Inject(method = "createEntity", at = @At("HEAD")) private void railwaysTweaks$fixDimensionalTrainCrash(Level level, boolean loadPassengers, CallbackInfo ci) { - ((CarriageAccessor) this$0).railwaysTweaks$getSerializedEntity().put( - "Pos", - railwaysTweaks$newDoubleList( - positionAnchor.x(), - positionAnchor.y(), - positionAnchor.z() - ) - ); + if (positionAnchor != null) { + ((CarriageAccessor) this$0).railwaysTweaks$getSerializedEntity().put( + "Pos", + railwaysTweaks$newDoubleList( + positionAnchor.x(), + positionAnchor.y(), + positionAnchor.z() + ) + ); + } } @WrapWithCondition(method = "createEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;moveTo(Lnet/minecraft/world/phys/Vec3;)V")) private boolean railwaysTweaks$fixDimensionalTrainCrash2(Entity instance, Vec3 vec) { - return false; + return positionAnchor != null; } @Unique