Baubles

Baubles

116M Downloads

JANI (Yet another Networking Issue)

Speiger opened this issue ยท 6 comments

commented

Well i was getting further into Baubles adding new features from IC2Classics side and i got a strange bugreport from one of my testers.
Lore: I made my jetpacks compatible with Baubles slots and what i did code wise was this:

	@Override
	public void onWornTick(ItemStack itemstack, EntityLivingBase entity)
	{
		if(entity instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer)entity;
			onArmorTick(player.getEntityWorld(), player, itemstack);
		}
	}

Then this bugreport came: https://youtu.be/gkOYGjJoKLM
(Its 50 seconds long) What the bugreport told was that the Jetpack did not update properly when switching into hovermode.
Turns out that baubles does not sync ItemStacks like Minecraft does with using the inventoryContainer to keep items in sync so as soon they change they would update.

This is what i had to do. And i am not proud of that but it was something i had to do:

	@Override
	public void onWornTick(ItemStack itemstack, EntityLivingBase entity)
	{
		if(entity instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer)entity;
			onArmorTick(player.getEntityWorld(), player, itemstack);
			BaublesApi.getBaublesHandler(player).setChanged(BaubleType.BODY.getValidSlots()[0], true);
		}
	}

My suggestion is to make inside of the Baubles Container which keep the baubles stored a Storage of lastTickBaubles which check every tick if the itemstacks have changed in any way then you do not need to add a markdirty function into your API. Also it would make my network spamming thing not needed.
(The jetpack logic is bound to armor tick and i didnt wanted to rewrite everything so i decided to do this).

And before you ask i am on the fixed version you made when i told you this network spamming issue.

I hope that helps you.

commented

IBauble.willAutoSync?

commented

hahaha well optionally yes that should be a thing.
Either that or just make autosync a default.

commented

That is already a thing. :)
I should have made my question clearer as in: What about using IBauble.willAutoSync?

commented

Ok that i did miss.. my mistake for updating the Mod on the server/client but not in the dev invioment.
But 10 Ticks is actually really slow for synchronizing stuff it should be every tick. For a jetpack for example this can be really important. (I have a mode which dissables the jetpack for a time so a fly effect does not get canceld out because other flying behaiors and if there is a 10 ticks delay it would not get synchornized fast enough)
This is because since 1.10.2 Servers can no longer force movement of entities you have to send a packet to the client and apply the motion there (a really annoying feature but this is how it is)

Also just a question when you create a boolean[] doesnt it default to all variables to false when you do not specially tell it to do differend?
(Reading Baubles sourcecode and i find clear things that could be improved)

commented

Stuff like disabling the jetpack is probably best handled with a specific packet.
Either way, it only syncs every 10 ticks to cut down on network traffic. Syncing like this will be used for cosmetic stuff 99% of the time and thus doesn't need to be tick accurate. In fact, it will never be tick accurate depending on your ping.
If you want it to sync more often you will need to use the code you posted above or (better) write you own code to check for changes and send the sync when it does.

Yeah, the Arrays.fill do not need to be there. There used to be an object involved there and I obviously forgot to take it out again.

Either way, closing this.

commented

fine with closing it. I am working on a small 1.10.2 patch. You can take a look at what i did and then you can decide if you want to take it or not.