From 78b491cf8d1a32206959d9089024aa5c32e60c2a Mon Sep 17 00:00:00 2001 From: screret <68943070+screret@users.noreply.github.com> Date: Fri, 3 May 2024 09:38:15 +0300 Subject: [PATCH] fix PlatformUtils#changeDimension not moving passengers to new dimension --- .../argent_matter/gcyr/util/PlatformUtils.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/argent_matter/gcyr/util/PlatformUtils.java b/src/main/java/argent_matter/gcyr/util/PlatformUtils.java index 4277f5c1..e1b5bcea 100644 --- a/src/main/java/argent_matter/gcyr/util/PlatformUtils.java +++ b/src/main/java/argent_matter/gcyr/util/PlatformUtils.java @@ -5,14 +5,26 @@ import net.minecraft.world.entity.Entity; import net.minecraftforge.common.util.ITeleporter; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; + public class PlatformUtils { - public static Entity changeDimension(Entity entity, ServerLevel newDim) { - return entity.changeDimension(newDim, new ITeleporter() { + public static Entity changeDimension(final Entity originalEntity, final ServerLevel newDim) { + List passengers = originalEntity.getPassengers(); + Entity dimensionChanged = originalEntity.changeDimension(newDim, new ITeleporter() { @Override public boolean playTeleportSound(ServerPlayer player, ServerLevel sourceWorld, ServerLevel destWorld) { return false; } }); + final Entity entity = Objects.requireNonNullElse(dimensionChanged, originalEntity); + passengers.forEach(passenger -> { + Entity newPassenger = PlatformUtils.changeDimension(passenger, newDim); + Objects.requireNonNullElse(newPassenger, passenger).startRiding(entity); + }); + return entity; } }