Jump to content

Recommended Posts

Posted (edited)

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
Posted (edited)
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
Posted (edited)
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
Posted (edited)
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
Posted
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

Posted (edited)

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)

Posted (edited)
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
Posted (edited)
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
Posted (edited)
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
Posted (edited)
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
Posted (edited)

"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
Posted (edited)
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
Posted
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?

Posted (edited)
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
Posted (edited)
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
Posted (edited)
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
Posted (edited)
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
Posted (edited)
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
Posted (edited)
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
Posted (edited)
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
Posted (edited)
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
Posted (edited)
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
Posted (edited)
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
Posted (edited)
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

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

×
×
  • Create New...

Important Information

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