Cadiboo Posted September 14, 2018 Posted September 14, 2018 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 Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
Animefan8888 Posted September 14, 2018 Posted September 14, 2018 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. Quote 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.
Cadiboo Posted September 14, 2018 Author Posted September 14, 2018 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? Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
Animefan8888 Posted September 14, 2018 Posted September 14, 2018 Just now, Cadiboo said: could you give me some examples of people using them? Here is an example, it is at the bottom of the class. Quote 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.
jabelar Posted September 14, 2018 Posted September 14, 2018 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. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Cadiboo Posted September 16, 2018 Author Posted September 16, 2018 Ok, I'm updating my code to use the default methods, how should I send a client->server update? Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
Animefan8888 Posted September 16, 2018 Posted September 16, 2018 1 hour ago, Cadiboo said: how should I send a client->server update? This requires a custom packet Quote 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.
Recommended Posts
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.