Jump to content

Force Update Forge All modded Capabilities For EntityPlayer


jredfox

Recommended Posts

I have the EntityPlayerMP object and new nbt for the player how do I force update this player object I got with some capabilities I got from another nbttagcompound? I want all forge capabilities to update since player.readFromNBT() doesn't do it for me.

Edited by jredfox
Link to comment
Share on other sites

9 hours ago, diesieben07 said:

Oh god, not this again...

 

  • You most likely do not want NBT.
  • Yes, readFromNBT reads the capability data.

I want to swap players capabilities all of them between two players if you use a certain item. ForgeCaps where the capabilities are always stored doesn't seem to update the capabilities readFromNBT(). I tested it with a couple mods they don't seem to sync of course they had guis. Maybe it's because it was a slightly older version but, I think the same issue persists is there a way to get around it like manually firing Entity Construction event?

Note everything is done via the server side

Edited by jredfox
Link to comment
Share on other sites

2 hours ago, diesieben07 said:

No, there is no API to make mods re-sync their data to the client.

not asking for one what makes it update to begin with it has to know or they wouldn't appear on startup and the capabilities also wouldn't be registered.

It also is resisted on the server could I simply unregister and re-register all of them or better yet make the player a whole new entity player object?

Edited by jredfox
Link to comment
Share on other sites

2 hours ago, diesieben07 said:

Mods probably send their data during PlayerLoggedInEvent and similar.

ok so would firing that event cause issues if somehow the capabilities get registered twice?

 

I will try and mess with this a bit more what happens when the player is cloned does that update everything where is the code starting when the player is being cloned?

Edited by jredfox
Link to comment
Share on other sites

46 minutes ago, diesieben07 said:

It will not cause capabilities to register twice (registration happens during AttachCapabilityEvent). However it will make all handlers fire, you will get all actions from mod that happen during player login. This is most likely not what you want.

 

I have no idea what you are trying to say. Updates happen when the mods see the need for it. There is no common entry point to "update everything". No, you cannot bend over backwards and make it magically appear. What you want is not possible.

well I needed it happen at x point there should be a method in forge like entities have readNBT() that's stupid if they never synced changes and never made a reset method or update all

Link to comment
Share on other sites

Misread the question

17 minutes ago, diesieben07 said:

I... what?

^^^ He makes a good point why would forge ever make something for you that you should make yourself by overriding about 3 methods?

 

You can have your tile entities extend a Base class that automagically handles this for you...

If this is what you would like, try looking at

https://www.programcreek.com/java-api-examples/?code=canitzp/Metalworks/Metalworks-master/src/main/java/de/canitzp/metalworks/machine/TileBase.java#

and

https://www.programcreek.com/java-api-examples/?code=canitzp/Metalworks/Metalworks-master/src/main/java/de/canitzp/metalworks/packet/PacketSyncTileEntity.java#

It automagically writes all your capabilities to NBT & syncs it every half second. 
I had quite a few problems with it (Not syncing even when explicitly told to, writing every face to NBT, syncing way too often). I've solved them so you might want to check out my implementation of it (my version can also write stuff other than caps to NBT)

 

My version of the Base tile class

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/tileentity/TileEntityBase.java

My Sync Packet class and my networking class

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/handler/network/PacketSyncTileEntity.java

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/handler/network/PacketHandler.java

2 classes that use it in my mod (Turbine is very simple, but only writes capabilities while Wire also writes "lastRecieved")

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/tileentity/TileEntityTurbine.java

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/tileentity/TileEntityWire.java

 

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

On 4/29/2018 at 4:34 AM, diesieben07 said:

Oh god, not this again...

 

  • You most likely do not want NBT.
  • Yes, readFromNBT reads the capability data.

ok then maybe the client isn't receiving the data. Does readEntityFromNBT() send a packet to the client maybe I need to create a packet to send to the client to update NBT? is there already a packet that does this?

 

I hope it's not the fact that the data doesn't change on the gui but, is changed on the capabilities so I can actually wip up a fix for mods with capabilities and guis

Edited by jredfox
Link to comment
Share on other sites

On 4/30/2018 at 4:37 AM, Cadiboo said:

Misread the question

^^^ He makes a good point why would forge ever make something for you that you should make yourself by overriding about 3 methods?

 

You can have your tile entities extend a Base class that automagically handles this for you...

If this is what you would like, try looking at

https://www.programcreek.com/java-api-examples/?code=canitzp/Metalworks/Metalworks-master/src/main/java/de/canitzp/metalworks/machine/TileBase.java#

and

https://www.programcreek.com/java-api-examples/?code=canitzp/Metalworks/Metalworks-master/src/main/java/de/canitzp/metalworks/packet/PacketSyncTileEntity.java#

It automagically writes all your capabilities to NBT & syncs it every half second. 
I had quite a few problems with it (Not syncing even when explicitly told to, writing every face to NBT, syncing way too often). I've solved them so you might want to check out my implementation of it (my version can also write stuff other than caps to NBT)

 

My version of the Base tile class

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/tileentity/TileEntityBase.java

My Sync Packet class and my networking class

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/handler/network/PacketSyncTileEntity.java

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/handler/network/PacketHandler.java

2 classes that use it in my mod (Turbine is very simple, but only writes capabilities while Wire also writes "lastRecieved")

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/tileentity/TileEntityTurbine.java

https://github.com/Cadiboo/WIPTech/blob/master/src/main/java/cadiboo/wiptech/tileentity/TileEntityWire.java

 

I don't want it syncing every second just when I want it updating and preferable the client isn't required server side mod only. What about a packet to readFromNBT() to the client and will that update the forge capabilities? So like a readFromNBT() packet to the client for capabilities only?

if you read it's not my object necessary it could be a player or another entity

stop with the crossing lines plz

Edited by jredfox
Link to comment
Share on other sites

46 minutes ago, diesieben07 said:

None of this is the case. Reading from NBT does not send a packet.

And such a packet does not exist. Reading from NBT on the client is not what you want. What you want is not possible.

well what I seen is there are two sides server and client both have nbt so if server has values updated and client does not then it should update capabilities on client side since they occur on both sides?

then what am I looking to do you said so yourself it should update capabilities data calling readFromNBT()

then why does the player inventory update when I say readFromNBT() on server and not capabilities that has to be client synced for the inventories what about capabilities. If it honestly isn't possible then this is a forge bug and should be reported since readFromNBT() should update data

Edited by jredfox
Link to comment
Share on other sites

39 minutes ago, diesieben07 said:

This is not how NBT works.

NBT is a data serialization format. It is used for saving to disk. The client does not "have NBT" (neither does the server, but it at least uses it).

 

It reads the server-side capability, yes.

 

The player inventory is constantly monitored by the game on the server side since it may change from certain events (e.g. you pick up an item) and synced if necessary. Not all capabilities do this, in fact most probably don't. This is fine, since there is no mechanism to "just update data of an entity". If you want to so, the best way is to kill the entity and spawn a new one.

 

readFromNBT is for when the entity is loaded from disk. You should not be calling it in the first place. This is not a bug. You are using things in ways they are not designed to be used.

"I used this screwdriver to polish my car, but it really didn't polish it. This screwdriver must be broken!"

readFromNBT() does occur on client look at the code there is no file argument. readFromNBT() is simply to update variables there is no file argument. There are also client only variables written to nbt does it get saved ever I don't know. Look at player.writeToNBT() in console on client and server side there are a couple tags on client that are not on server.

Silkspawners main mechanic is to break block save it to stack (writeToNBT) and placeBlock(readFromNBT) both of which are never saved to the disk during that process until the itemstack or tile entity decides to save the data. The client even had to readFromNBT of the tile entity otherwise for a couple ticks it would display pig. Those methods are for saving .comparing, and manipulating data which means it's not always stored to the disk but, yes eventually that's it's main function is serialization with the exception of commands and mods that decide to do stuff to manipulate and update variables

you are talking about serialization methods yes those occur only from the disk and do call readFromNBT() after they get the nbt

Edited by jredfox
Link to comment
Share on other sites

"If you want to so, the best way is to kill the entity and spawn a new one."

Ok how do I do this make the player = new player and then tell client it's a new player then use it to update from the nbt I gathered from a file I serialized to nbt?

I heard something about player cloning how do I do this on command while still serializing from nbt?

Edited by jredfox
Link to comment
Share on other sites

11 minutes ago, diesieben07 said:

Where? If you are so sure about it, post exact locations where the client calls it.

 

Wat? How is that relevant?

 

This is complete bs. The client never saves an entity to NBT. Please clarify which client only variables you are talking about.

 

TileEntities are something else. They use (in vanilla, mods do not necessarily use this) NBT for syncing the data to the client. This is a completely separate process and does not use the same methods as saving to disk.

 

Regarding players you'd probably have to do some form of the respawning process. But this might make data disappear, since some mods will reset counters, stats, etc. on death/respawn.

 

Ultimately again: What you want is not possible, since there are no APIs for it. There is no concept of "apply new data to this entity" in Minecraft.

you said create a new one. How do I clone the player then with a different nbt then it's own and set it to be the new player for the client? Assuming I already set the uuid most and least from the current player?

Edited by jredfox
Link to comment
Share on other sites

1 minute ago, diesieben07 said:

Look at the respawning process for how to clone the player. Then deserialize the new instance from your modified NBT before fully respawning it.

It might work. It might break completely.

 

Also, please stop referring to things "having NBT". It is wildly inaccurate and conveys a wrong understanding about how all of this works.

Well the re spawn process doesn't even give out a new player I am pretty sure but, I will check it out. 

What about when the client logs onto the server and the entity is created there can that be hacked into giving out a new player from the old one? Where is that code located at?

Link to comment
Share on other sites

6 minutes ago, diesieben07 said:

Yes, it does. This is why PlayerEvent.Clone exists.

 

We already had this. It would trigger everything that happens on login, such as welcome messages, login stats, etc.

Well I could simply look at the logic and not fire the forge events so the messages don't appear and manually handle the capabilities

the player event clone exists but, I have no clue when it's fired? I believe I tried dying before and it didn't fire let me check

Edited by jredfox
Link to comment
Share on other sites

9 minutes ago, diesieben07 said:

No, because the events are what tell the mods "hey, player logged in" and then the mods send their data. For the millionth time: There is no API to say to a capability "please sync yourself to the client". No, even if you bend over backwards. IT DOES NOT EXIST.

 

Then look at the god damn code. You have an IDE. USE IT.

must have been on the wrong bus in older versions last time I tried it. It does occur during respawn sometime. this might be enough data to do what I need. will write back if it's not

Ok it appears I have found more questions then answers:
the player clone event doesn't fire on player death
the player clone event only fires when the client hits the respawn button are you sure this is the code I should be looking at?

Edited by jredfox
Link to comment
Share on other sites

2 hours ago, diesieben07 said:

Indeed, why would it?

 

Yes, like I said you need to adapt the code. Cut out the whole "okay client, please show respawn gui" - "okay server, respawn button was pressed" process and just do the respawn immediately.

It would help if I knew what class it's in

The client code just leads to a packet being sent it could be anywhere that the server does something with it:
 

    public void respawnPlayer()
    {
        this.connection.sendPacket(new CPacketClientStatus(CPacketClientStatus.State.PERFORM_RESPAWN));
    }

 

 

Edit: It appears I found it in the network connection from entity player mp. It has alot of code not going to want to use it all like reset positions and dimensions I handled that before I would call the manual respawn.

Edited by jredfox
Link to comment
Share on other sites

4 hours ago, loordgek said:

@jredfox  what are you making for mod ??

two things a test item to swap playerdata between two players and a uuidfixer(if change is dedicated force update everything). Trying to get it working without player re logging.

right now just trying to get it working from a hard coded playerdata without player re logging 

Could be used as a magic spell for the test item if someone wanted to use it 

Edited by jredfox
Link to comment
Share on other sites

20 hours ago, diesieben07 said:

Indeed, why would it?

 

Yes, like I said you need to adapt the code. Cut out the whole "okay client, please show respawn gui" - "okay server, respawn button was pressed" process and just do the respawn immediately.

Ok I have confirmed what you said there is no such update method without re logging. I physically made the player a new object and the capabilities still didn't update and sync with everything else.

I think there should be in the future an updateCapability() and updateAllCapabilities() method in forge based where you give it the nbt to re-serialize it. Since resource location is already required you should be able to send in the resource location and nbt to update the capability or give it everything and update all

Edited by jredfox
Link to comment
Share on other sites

15 hours ago, diesieben07 said:

Indeed, why would it?

 

Yes, like I said you need to adapt the code. Cut out the whole "okay client, please show respawn gui" - "okay server, respawn button was pressed" process and just do the respawn immediately.

 

ok so I set the player connection location forceably disconnect the player and the position doesn't get saved. How many ticks before I can disconnect the player after the players location changes?

Note this is all done on server side and the set is a new set nothing added. Also note this is done on server side only and is integrated when testing.

p.connection.setPlayerLocation(x, y, z, e.rotationYaw, e.rotationPitch, set);
p.connection.disconnect(new TextComponentString("UUID Change Relog For Syninc Forge Capabilities"));



As for the spell thing I will just tell people it doesn't always sync with capabilities relog manually if you want it to update.

Edited by jredfox
Link to comment
Share on other sites

17 minutes ago, diesieben07 said:

What... why are you disconnecting the player O.o

for my uuidfixer/checker if detected uuid is different readEntityFromNBT(proper) then teleport and discconect so forge capabilities are properly synced.

the uuid bug occurs when either the launcher sends the wrong information, mojang sends the wrong information, either one updated, or many other things I can't think of but, when that occurs playerdata wipes. My event is to prevent this regardless of launcher,mojang website response, or mc version. I have verified this 1.7.2-1.12.2 I cannot easily reproduce the bug but, I can simulate when the data is wrong does my patching work.

So the only thing that's not working is the coords even though I set them right before I disconnected the player it doesn't appear in the disk but, the dimension id and everything else did appear. I printed the pos of the player right before disconnection and it was the new pos I sent it but, not on the disk weird.

If I don't disconnect the player the coords will properly sync so how long before I should be able to disconnect the player without stuff not syning even though all those calls are on serve

Edited by jredfox
Link to comment
Share on other sites

10 minutes ago, diesieben07 said:

What... WHATTTTT...

Do not tell me you are trying to change a player's UUID. This does not work.

 

Oh god, this again? We had this like a year ago it seems. You have failed to properly tell me how to reproduce this bug, if I remember correctly. You need to stop employing more and more hacks to work around the issues your own broken code causes.

no I check if the uuid has changed if it has I attempt to patch it. I am unable to reproduce this bug easily all I know is it does occur very rarely probably issues with website/launcher but, it does occur.

What am I talking about:
go into a world previously full inventory and say in a different dimension

eventually through time keep going back into the world and your uuid changes your player data is new and your progress all lost even though you are the same player, the level.dat backup failed for integrated server, and you have the same username. You can manually patch this by going to your old playerdata renaming the uuid most and least and rename the file to your new uuid but, my event is to automate this

Anyways how can I properly sync coords before disconnecting the player how many ticks do I have to wait one two? what's not syncing?

Should I be dependent upon vanilla saving it's stuff for the player or use an event handler to fix this issue by overriding everything when it occurs(not optimized)?


My mod doesn't change player's uuid at all. I am attempting to fix a vanilla issue that can be observed in both vanilla and forge without my mod installed or any other mods installed. It has nothing to do with me. uuidfixer is to simply fix the bug by patching data over when the player decieds to change it on it's own. Again it can be observed without any mods besides forge for sure

Edited by jredfox
Link to comment
Share on other sites

4 minutes ago, diesieben07 said:

The thing is, nobody but you seems to have this bug.

 

And I still fail to understand why you want to disconnect the player.

zdoctor, choonster,micah_laster,all my freinds, hundreds of people on the mc forum know what I am talking about all they know is how to manually fix it when it occurs. They don't call it uuid bug but, they do know to mess with those tags like I said before and change the file name to the new file

Edited by jredfox
Link to comment
Share on other sites

5 minutes ago, diesieben07 said:

The thing is, nobody but you seems to have this bug.

 

And I still fail to understand why you want to disconnect the player.

you said forge capabilities refuse to update without relog I am forcing user to relog because I agreed with you.

The issue is positions don't write to nbt if I disconnect the player on the same tick

Edited by jredfox
Link to comment
Share on other sites

1 minute ago, diesieben07 said:

So you are telling me hundreds of people on some other forum have this bug. Yet none of them have ever arrived on this forum?

And you are telling me that none of these hundreds of people have ever decided to report a bug to Forge? Or to Mojang, if it is the launcher or "the website" as you say.

And you are telling me that none of these hundreds of people have ever found a way to reliably reproduce it?

 

I call bs.

https://www.minecraftforum.net/forums/support/java-edition-support/2225159-1-7-10-custom-modpack-player-data-randomly

2 seconds later

Edited by jredfox
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.

Announcements



×
×
  • Create New...

Important Information

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