Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

 

Thanks!

~Nielsbwashere

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.

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
/...
} 
x++
}

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

TE's already have functions that handle this.

 

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

@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
	readFromNBT(packet.func_148857_g());
}

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.