#fake metadata
1 messages ยท Page 1 of 1 (latest)
ok
great!
what i was about to ask you (a thread)
so tell me ur knowledge wise programmer
๐
how do you do fake metadata
https://www.spigotmc.org/threads/understanding-protocollib-packets.529392/
This shitty tutorial I wrote a while ago covers the protocollib side
i'm not tho
i better shut my mouth
You'll need to have an NMS entity, the type doesn't matter
ProtocolLib internally just makes a fake egg that's never spawned in
i tried with NMS, but no success due to datawatchers, whenever i try to send a ClientboundEntityMetadataPacket, it requires an EntitySyncheed (previously called DataWatcher)
that's the problem
the NMS entity is bound to the server, so whenever something happens on the client, it will happen on the server too
i mean, how do you make a fake entity in the first place
You can create an nms entity instance and just... not spawn it in
yes ofc, but then i have another problem
I'd need to "deep copy" an existing entity into that fake entity
Yeah that's easy
because what i'm trying to do is just "fake update" an existing (on server and client) entity
SynchedEntityData#getAll
SynchedEntityData#assignValues
Entity originalEntity = ...; // original nms entity
SynchedEntityData originalData = originalEntity.getEntityData(); // original nms entity data
ThrownEgg egg = new ThrownEgg(EntityType.EGG, null);
SynchedEntityData datawatcher = egg.getEntityData();
datawatcher.assignValues(originalData.getAll()); // deep copy the original data
datawatcher.set(new EntityDataAccessor<>(123, EntityDataSerializers.BOOLEAN), true);
ClientboundSetEntityDataPacket packet = new ClientboundSetEntityDataPacket(original.getId(), datawatcher, true);
not that hard
aha i see
So ur sure that originalEntity will not be updated too (due to some madness in datawatchers that would be somehow connected by the entity id or sth)
try it and see
datawatcher.set(new EntityDataAccessor<>(123, EntityDataSerializers.BOOLEAN), true);
What does this do?
and why 123
sets the field at index 123 with the boolean value of true
123 will obviously crash the client, you need to find the metadata id in the protocol page
in the protocol page, i find no field with index 123
Why do we have to set such field to true? To not crash the client? Why would it if set to false?
ye
i see thank you
now i need your opinion on sth else related to packets
Here's my current situation:
I keep spamming packets that updates the map of certain ID (with new data/image) to players, in order to make "animated images", works flawlessly
There are plenty of optimisations too I done, which happen dynamically according to their TPS (send the packet if the entity the map is bound to is within their view distance, not hidden, and at a more less far distance/view angle according to their TPS, also i higher or lower the framerate according to their TPS)
I don't think I could have done it better tbh, except for one stuff.
Since I'm tracking the entities too (the itemframes) to do the optimisations I mentioned above, I imagined the following scenario:
Instead of sending them packets to UPDATE a certain map continuously, generate N fake entities (fake itemframes), N being the amount of frames of the gif. Send them only once the packet to update each map id of the frames. Then I can assume that they cached every frames of the gif in their client (each corresponding to a different map id), and what i keep spamming them is fake entity update packets, to fake change the map id inside of the itemframe they are viewing.
Ooh maps
make sure you optimize the basics first
color maps, optimize raytracing if you're doing that
I was thinking doing this change because my theory is that entity update packets are lighter than "map packets"
They are, yes
all done!
how extreme 
i worked 2 years on this. (i'm a slow programmer, but essentially it's the work of my life)
Done any graphs?
xd
I've had a period of my life where I worked nonstop for like a week without sleep, just optimizing this very problem
well, i have let it very customizable (dynamic framerate, adjustable view distance, view angle, and so on, based on their tps) but haven't got time to tweak the configs optimally (didn't do much testing)
I mean micro optimization
Like making sure that any raycasting runs under 100 microseconds etc
oh yeah, that is done really really well and my algorithm for ray tracing is pretty smart i think (O(n) with n the distance from player to itemframe entity)
Run a few iterations and time it :)
I've talked about it here https://github.com/cerus/maps/issues/6#issuecomment-1249093651
something tells me we already had this conversation like 3 months ago?
will do ^^ (i first have to fix my workaround, which has no java, no IDE etc) (new comp)
very possibly yes
i made a break
(a full stop to be precise)
cuz studies are intense haha
so do you think that this optimisation would be worth it?
Uhh, possibly
the client can have some issues handling it though
like flickers and all
yeah ofc
with my current code, no flickers on JE and no flickers on BE
pretty smooth even
I'd just hope that i can spam more to phones at the same time
cuz rn it works for phone players, but cuz i cap for them at 10 map updates at a time
Try limiting your connection somehow
to like 100kbps
and trying it out
on a remote server obviously
That'll give you a feel for the experience
u want me to play MC from a remote server on which i cap the connection for testing purposes?
yeah true
thx for the tip
also, do you think that (given that i tweaked it so TPS does update at an extremly small interval instead of 5 seconds by default) TPS is a good measurement for player lag?
no
Ping is a nice measurement for player lag
you should do the rendering part async
so there's no point in measuring tps
my bad i meant ping indeed
lol i'm dumb
i mismatched the words
but yeah i meant ping ofc
Well... ping isn't always accurate but it's as close as it gets
ping matters a lot jess than jitter, for example
i already do it async, but people here told me that the packets are eventually sent sync (even if sent from side theads, they eventually get queued, and dispatched synchronously)
They're dispatched in their own dedicated thread
well i do it async already^^
my server handles it very well (no freeze, or lag for the server)
Anyway thank you @scarlet oar, if i get the courage to maintain it, i'll keep you updated; and i have plenty on my list and probably another lifetime to spend on this haha, for example i'm not satisfied enough with floyd steinberg dithering, and i'm planning to pick on heaviier error diffusing algorithms, and i'm also considering do some "animation dithering" (essentially when a red pixel quickly turns to a blue pixel, it gives the Illusion of a purple pixel)
the biggest thing is probably testing tho,
cuz ur right, i really need to have a clearer idea of what type of connection can support what
that's not updating anything, any chance i have to send a spawn packet too?
added a spawn packet too, didn't change anything
oh sorry, fake alert!
it works
actually it's cuz i'm so dumb, i tested it inside "PlayerInteractEntityEvent" LOL
So obv when the event triggers, afterwards the entity updates (unless the event is cancelled, thing which i haven't done) to what it is supposed to be (not fake) lol
You might want to intercept packets and "fix" data
no, because i have to send a different packet every .1 second
protocollib is good when you just wanna make sure they get an illusion
But not only i want to make an illusion, i also want to change this illusion to another illusion constantly
the puns
๐
@scarlet oar brooooo, crazy shit
So I made the update I talked to you about and the change is really significant.
To give you an example, in my horny dungeon with loads and loads of GIFs, pictures have 5x6 dimensions so it's really a big amount of maps, before the caching+"fake metadata" update, I would get maybe 3000ms ping with my connection. (In the situation where I do look at most pictures so most of them have to animate). Now I may get these 3000 ms for the "download" time only. Once frames are all cached in the client, further animation doesn't make them lag at all. Now I could be at 30ms while watching them all haha.
To fix that "download" lag, I will add a dynamic config for my plugin (configurable mathematical function according to player ping) which would determinate the maximal "download" rate. When the server is about to send a new frame to client (and for the first time, which means servers needs to send the map data too so the client can "download"), but the amount of frames sent to this client exceeds the download rate, server will not send the map data this time. (But will do it later on, when the queue will be less busy), which means ofc that the gif might be longer to load for client ofc.
Ofc I could already have added this feature before this update, but since it was "constant downloading" (no caching involved), it would affect the overall framerate. (Which is a bit unfortunate)
or you can just... not download them on the network thread and wait a bit?
Yeah but I want to load it as fast as possible for client, based on their ping
So if someone has a great connection, why making load as slow as someone who lives in Congo
Thats the whole point of dynamic configs ๐
Adapt to the user
Just like bunch other settings like view angle, view distance which varies based on player ping