ProtocolLib

3M Downloads

WorldKeys Modifier overrides worlds to default world

TheTrueSam opened this issue ยท 1 comments

commented

Describe the bug
Worlds written in the WorldKeys Modifier of a packet container get overwritten with the default world.

To Reproduce
Steps to reproduce the behavior:
Create a server with at least two worlds.
Let minecraft load the default world and use a plugin to load the second world and enter it.
Run the following code:
`try
{
PacketContainer container = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.RESPAWN);

	    container.getDimensions().write(0, ((CraftPlayer)p).getWorld().getEnvironment().getId());
	    container.getWorldKeys().write(0, p.getWorld());
	    container.getLongs().write(0, (long)(BiomeManager.a(p.getWorld().getSeed())));
	    container.getGameModes().write(0, NativeGameMode.fromBukkit(p.getGameMode()));
	    container.getGameModes().write(1, NativeGameMode.fromBukkit(p.getGameMode()));
	    container.getBooleans().write(0, false); //isDebug
	    container.getBooleans().write(1, false); //isFlat
	    container.getBooleans().write(2, false); //Copy metadata, true if dim changed

	    LogSystem.get().info("Creating nick packet with world " + p.getWorld().getName());
	    LogSystem.get().info("Creating nick packet internal: " + container.getWorldKeys().read(0).getName());
	    
	    //https://wiki.vg/Protocol#Respawn
	    
	    ProtocolLibrary.getProtocolManager().sendServerPacket(p, container);
	}
	catch (InvocationTargetException e)
	{
		LogSystem.get().warn("Failed to send respawn packet while updating nickname", e);
	}`

The following log messages can be observed:
`[19:06:50] [Server thread/INFO]: Creating nick packet with world airships22000

[19:06:50] [Server thread/INFO]: Creating nick packet internal: worlds/lobby22000`

Expected behavior
When reading the world back the same world should be returned as the one that was written.
Sidenote: When sending the packet the world in the packet sent to the player is also the default world and not the entered one.
This can be verified using the F3 menu and looking at the last line of the first stack of information.
When you're in the default world "minecraft:overworld" will be displayed, otherwise "minecraft:WORLDNAME"

Version Info
https://pastebin.com/n3Rjykpt

Additional context
The server uses ViaVersion but that should not matter since the world is already wrong before sending the packet.

commented

@dmulloy2, any news about this?..