From 9fec679b0349cbc4d508dd76b5f8f6664d53b54e Mon Sep 17 00:00:00 2001 From: s809 <11816467-s809@users.noreply.gitlab.com> Date: Tue, 1 Aug 2023 17:04:40 +0500 Subject: [PATCH] Attempt to fix dimension switching --- fabric/build.gradle | 1 + .../distanthorizons/fabric/FabricServerProxy.java | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/fabric/build.gradle b/fabric/build.gradle index c3fc3acef..93f87e720 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -61,6 +61,7 @@ dependencies { addModJar(fabricApi.module("fabric-rendering-v1", rootProject.fabric_api_version)) // TODO: Remove this as it is only needed in 1 line (FabricClientProxy) addModJar(fabricApi.module("fabric-api-base", rootProject.fabric_api_version)) addModJar(fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version)) + addModJar(fabricApi.module("fabric-entity-events-v1", rootProject.fabric_api_version)) // Mod Menu modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}") diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricServerProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricServerProxy.java index d7739e9c2..d877fbaf1 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricServerProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricServerProxy.java @@ -10,6 +10,7 @@ import com.seibel.distanthorizons.core.api.internal.ServerApi; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.ILevelWrapper; +import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; @@ -137,6 +138,17 @@ public class FabricServerProxy ServerApi.INSTANCE.serverPlayerDisconnectEvent(getServerPlayerWrapper(handler.player)); } }); + ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register((player, origin, dest) -> + { + if (isValidTime()) + { + ServerApi.INSTANCE.serverPlayerLevelChangeEvent( + getServerPlayerWrapper(player), + getServerLevelWrapper(origin), + getServerLevelWrapper(dest) + ); + } + }); } }