Jump to content

Saving up CPU (Packets, etc.)


Recommended Posts

Hi everyone,

I am working on a mod; which includes a tile entity that updates and sends packets to the player.

The problem that I am having; is that the game is having huge lag since it is updating too frequently, also this block is used like a lot so it should be so it doesn't lag with a lot of them in the world.


Do you have any tips and tricks on how to make it so it updates every ? ticks?

This will help a lot.




Link to comment
Share on other sites

Just so you know - ANY packet system that is NOT based on client-request<->server-response (like opening conatiner/gui, walking into area, being in area, some clicking actions, buttons) will be generating a lot of lags when used in too many 'places'.


Let's take example of server-data->client-data (no-request-system):

Synchronization of player data!

So compare player to TileEntity - one is from 0 to few hundreds (that would be good server), other one (TE) is infinite.


Rethink you design:

Does your Player need to know what's happening in all TE in WHOLE server world?

If not - consider adding entity scanner in your TE, if Entity instanceof Player -> send packet.

Does your Player even need that data at all times?

Maybe you could make this code from server-data->client-data to client-request<->server-response.


Also: "Do you have any tips and tricks on how to make it so it updates every ? ticks?"

What you mean? TE is alredy being updated on tick (or not? enlighten me)?

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Do you have any tips and tricks on how to make it so it updates every ? ticks?

Uhm, you mean some kind of like that:

int x = 0;
public void updateEntity(){
if(x == 40) {
x = 0

It would be probably smarter to send packets only if the data actually changed, just set a boolean whenever you are changing the data and check for the boolean when you are sending the packet, wich, I assume you do in updateEntity()

Link to comment
Share on other sites

TE's already have functions that handle this.


public Packet getDescriptionPacket() {
	NBTTagCompound nbtTag = new NBTTagCompound();
	return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbtTag);

public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {

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.

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.