Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServerboundMovePlayerPacket error when using changeDimension to fantasy dimensions, chunks do not generate #39

Open
filloax opened this issue Dec 6, 2023 · 10 comments

Comments

@filloax
Copy link

filloax commented Dec 6, 2023

As title. Trying the lib by using a simple command that creates a temporary dimension and moves the player there, but I just get the classic pre-loading empty world on the client side as chunks never generate, with the error at the bottom of the issue post in the log.

The command code (in Kotlin, mojmap, fabric) is this:

object Commands {
    val worldConfig = { server: MinecraftServer ->
        RuntimeWorldConfig()
            .setDimensionType(BuiltinDimensionTypes.OVERWORLD)
            .setDifficulty(Difficulty.HARD)
            .setGameRule(GameRules.RULE_DAYLIGHT, false)
            .setGenerator(server.overworld().chunkSource.generator)
            .setSeed(1234L)
    }

    fun register(dispatcher: CommandDispatcher<CommandSourceStack>, registryAccess: CommandBuildContext, environment: Commands.CommandSelection) {
        //tmpdim: move to temporary dim
        dispatcher.register(literal("tmpdim").requires{ it.hasPermission(2) }
            .executes { ctx ->
                val fantasy = Fantasy.get(ctx.source.server)
                val worldHandle:= fantasy.openTemporaryWorld(worldConfig(ctx.source.server))
                val level = worldHandle.asWorld()
                ctx.source.playerOrException.changeDimension(level)

                1
            }
        )
    }
}

Am I doing something wrong?

[20:54:42] [Server thread/ERROR] (Minecraft) Failed to handle packet net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot@380fc290, suppressing error
 java.lang.NullPointerException: Cannot invoke "it.unimi.dsi.fastutil.objects.ObjectSet.remove(Object)" because "objectSet" is null
	at net.minecraft.server.level.DistanceManager.removePlayer(DistanceManager.java:225) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.level.ChunkMap.move(ChunkMap.java:1093) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.level.ServerChunkCache.move(ServerChunkCache.java:477) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.handleMovePlayer(ServerGamePacketListenerImpl.java:928) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.network.protocol.game.ServerboundMovePlayerPacket.handle(ServerboundMovePlayerPacket.java:31) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot.handle(ServerboundMovePlayerPacket.java:90) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.network.protocol.PacketUtils.method_11072(PacketUtils.java:34) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.TickTask.run(TickTask.java:20) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:143) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:797) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:189) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:114) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:780) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:774) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.util.thread.BlockableEventLoop.runAllTasks(BlockableEventLoop.java:103) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:760) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:696) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:252) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
[20:54:42] [Server thread/ERROR] (Minecraft) Failed to handle packet net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos@5f723ccf, suppressing error
 java.lang.NullPointerException: Cannot invoke "it.unimi.dsi.fastutil.objects.ObjectSet.remove(Object)" because "objectSet" is null
	at net.minecraft.server.level.DistanceManager.removePlayer(DistanceManager.java:225) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.level.ChunkMap.move(ChunkMap.java:1093) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.level.ServerChunkCache.move(ServerChunkCache.java:477) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.handleMovePlayer(ServerGamePacketListenerImpl.java:928) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.network.protocol.game.ServerboundMovePlayerPacket.handle(ServerboundMovePlayerPacket.java:31) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos.handle(ServerboundMovePlayerPacket.java:68) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.network.protocol.PacketUtils.method_11072(PacketUtils.java:34) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.TickTask.run(TickTask.java:20) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:143) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:797) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:189) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:114) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:780) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:774) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.util.thread.BlockableEventLoop.runAllTasks(BlockableEventLoop.java:103) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:760) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:696) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:252) ~[minecraft-common-c4cba8cea8-1.20.2-loom.mappings.1_20_2.layered+hash.405084424-v2.jar:?]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]
@filloax
Copy link
Author

filloax commented Dec 6, 2023

For context, this is on 1.20.2, fabric ver 0.91.1+1.20.2, fantasy ver 0.4.11+1.20-rc1

@Libreh
Copy link

Libreh commented Feb 10, 2024

I can re-produce this as well.

@Earthcomputer
Copy link

For custom dimensions, you are supposed to use FabricDimensions.teleport or ServerPlayer.teleportTo instead of ServerPlayer.changeDimension.

@Libreh
Copy link

Libreh commented Jul 25, 2024

For custom dimensions, you are supposed to use FabricDimensions.teleport or ServerPlayer.teleportTo instead of ServerPlayer.changeDimension.

I forgot about this issue but yeah this fixed it for me in case anyone was wondering what the fix was/if it would work.

@CaelTheColher
Copy link

CaelTheColher commented Aug 19, 2024

I'm having the same issue on 1.21 while using ServerPlayer.teleportTo, and Fabric Dimensions no longer exists in this version

edit: I think its an issue with trying to teleport the player as soon as the dimension is created? Creating the dimension earlier (in my case, on ServerLifecycleEvents.SERVER_STARTED) seems to stop this from happening.

@CaelTheColher
Copy link

Ok I'm back to having no clue. I made a command to create a dimension and another to teleport to it and that seems to work fine but then it breaks the original dimension created on server start? Even though they are two separate dimensions

@Earthcomputer
Copy link

@CaelTheColher in 1.21, FabricDimensions.teleport has been removed, you can just use Entity.teleportTo.

@CaelTheColher
Copy link

CaelTheColher commented Aug 19, 2024

@CaelTheColher in 1.21, FabricDimensions.teleport has been removed, you can just use Entity.teleportTo.

I am already using teleportTo, but still getting the same error as op

@CaelTheColher
Copy link

I found the problem, I was teleporting on the ServerPlayConnectionEvents.JOIN event, but that is too early and it can mess things up

@Libreh
Copy link

Libreh commented Aug 20, 2024

I found the problem, I was teleporting on the ServerPlayConnectionEvents.JOIN event, but that is too early and it can mess things up

What I like to do is have a playerJoined UUID list and then teleport the player on next server tick, if you want compatibility with VMP you can also make sure the notInAnyWorld field is false before running anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants