Jump to content

[1.10.2] Server doesn't send NBT data to client when they log in to server


kajacx

Recommended Posts

I have began implementing tile entity teleportation for my mod, then updated to 1.10.2 and then found a stunning bug (at least in my opinion). When client logs into a server, that server no longer sends the client the NBT data about surrounding tile entities, at least not correctly.

 

My Tile entity is a custom chest, and I have chosen to store facing in NBT instead of metadata, since it seemed like less work for me. But the NBT synchronization is completely ludicrous now. Code:

 

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound compound) {
        super.writeToNBT(compound);

        String location = thiz.getWorld().isRemote ? "Client" : "Server";
        L.d(" -- " + location + " WRITE TO NBT -- ");

        L.d(location + " write facing: " + thiz.facing.getHorizontalIndex());
        compound.setInteger("Facing", thiz.facing.getHorizontalIndex());

        int rngCode = MathUtils.random.nextInt(1_000_000);
        L.d(location + " write rng code to: " + rngCode);
        compound.setInteger("RandomInt", rngCode);

        return compound;
    }

    @Override
    public void readFromNBT(NBTTagCompound compound) {
        super.readFromNBT(compound);

        String location = thiz.getWorld() == null ? "Unknown" : (thiz.getWorld().isRemote ? "Client" : "Server");
        L.d(" -- " + location + " READ FROM NBT -- ");

        int facingInt = compound.getInteger("Facing");
        L.d(location + " read Facing int: " + facingInt);

        EnumFacing facing = EnumFacing.getHorizontal(facingInt);
        L.d(location + " read Facing: " + facing);

        this.setEnumFacing(facing);

        L.d(location + " read rng: " + compound.getInteger("RandomInt"));

    }

 

I have also added some random code for more testing. This is what hapeens when I place my tile entity for the first time in world:

 

[18:30:00] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug:  -- Server WRITE TO NBT --

[18:30:00] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Server write facing: 3

[18:30:00] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Server write rng code to: 240286

[18:30:00] [Client thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug:  -- Client READ FROM NBT --

[18:30:00] [Client thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Client read Facing int: 3

[18:30:00] [Client thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Client read Facing: east

[18:30:00] [Client thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Client read rng: 240286

(after a while)

[18:30:01] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug:  -- Server WRITE TO NBT --

[18:30:01] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Server write facing: 3

[18:30:01] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Server write rng code to: 819099

 

So the first write-read is server sending NBT to client, the second write on server is server saving NBT internally, everything works as intended.

But then, I log out and log in, and this is displayed on login:

 

[18:33:55] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug:  -- Unknown READ FROM NBT --

[18:33:55] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Unknown read Facing int: 3

[18:33:55] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Unknown read Facing: east

[18:33:55] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Unknown read rng: 819099

(a bunch of messages here, "kajacx logged into game", etc...)

[18:33:56] [Client thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug:  -- Client READ FROM NBT --

[18:33:56] [Client thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Client read Facing int: 0

[18:33:56] [Client thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Client read Facing: south

[18:33:56] [Client thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Client read rng: 0

[18:33:56] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug:  -- Server WRITE TO NBT --

[18:33:56] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Server write facing: 3

[18:33:56] [server thread/INFO] [sTDOUT]: [com.hrkalk.zetapower.utils.L:d:32]: Debug: Server write rng code to: 816604

 

And it just doesn't work. Why on earth does minecraft not send NBT to clients who log in? The facing is saved on server correctly (I have tested this), but on client, it just thinks the tile entity is facing south and renderes it as such.

 

I can guess that the solution could be to send the update packet myself, BUT:

1) writing code that sends NBT of existing tile entities to client when they log in is retarded, MC should do this on it's own

2) such message send data via ByteBuf, which would be fine, except you cannot store NBT in ByteBuf (WTF?) since there is no method for in the ByteBuf class nor is NBT serializable (really?)

 

This just seems like a gigantic mess, and the worst part is, that the tile entity teleportation part acctually works! When I teleport my tile entity on server from one place to another and then set it's NBT, it is acctually send to the client automaticly (well, the getUpdatePacket and onDataPacket are called, which I implemented to just read/write NBT, but they are called automaticly).

 

So, how to force minecraft to send NBT information to players who log in to server, without using that packet system that uses ByteBuf, since that can't store NBT?

Link to comment
Share on other sites

You need to override getUpdateTag()

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

This is a forum, not Stack Exchange. You don't.

 

If you want to edit your original post and change the title so it says "[sOLVED]" that's sufficient, but not required.  You're also free to click the "thanks" button if you want.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.