Jump to content

[1.12.2] delaying syncing of tile entity to client


Recommended Posts

Posted

I'm sending a sync packet in my TileEntity.onLoad method and its getting to the client before the tile entity is created on the client, is there any way to delay sending the packet or send the packet after the tile entity exists on the client?

 

my code:

https://github.com/Cadiboo/WIPTechAlpha/blob/d38b6f136293df8cbb606f1781f1d4b56c0c698d/src/main/java/cadiboo/wiptech/tileentity/TileEntityPeripheral.java#L84-L88

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
2 minutes ago, Cadiboo said:

I'm sending a sync packet in my TileEntity.onLoad method and its getting to the client before the tile entity is created on the client, is there any way to delay sending the packet or send the packet after the tile entity exists on the client?

I don't think you need to send a custom packet. You should just override the default sync methods in the TileEntity class. But if this is what you need to do send a packet from the client to the server from onLoad and then send a packet back syncing the TE.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
2 minutes ago, Animefan8888 said:

I don't think you need to send a custom packet. You should just override the default sync methods in the TileEntity class. But if this is what you need to do send a packet from the client to the server from onLoad and then send a packet back syncing the TE.

I was trying to avoid using a sync request. I've always used custom packets because I couldn't figure out the default sync methods when I first started modding, could you give me some examples of people using them?

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

This problem is common on entity and tile entity creation where you might want to make sure the client-side is fully instantiated and initialized before doing something. As mentioned there are some ways to do that already (like entities have spawn data mechanism).

 

But I admit sometimes I just send a delayed packet. It is really easy to do it, just create a boolean field in your tile entity called something like initPacketSent and init that to false. Then in your update method that runs every tick, just check if it is false and if so send the packet and set to true. This should delay the packet until the first time the update method is run which is usually the tick after creation and usually sufficient delay. If you want to delay more and really be sure then instead of a boolean just use a int value (like 5 for five ticks) and count down in your update method.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Ok, I'm updating my code to use the default methods, how should I send a client->server update?

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)

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.