Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disguise api #10478

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yannicklamprecht
Copy link
Contributor

@yannicklamprecht yannicklamprecht commented Apr 28, 2024

relates to #10584

Adds a simple disguise api that also makes sure that invalid entity data, not belonging to the type that is faked, is filtered.
It also adds a server generator module to reduce maintenance of the entity data filter.

tldr; The API provides a way to disguise any entity as another or a player with having the possibility to interact with the entity like with any others. The big advantage is that you've the whole vanilla logic and Mob Goal and Pathfinding included without hassle.

Testing the changes can be done using the following snippet:
https://gist.github.com/yannicklamprecht/639acba127a54f5617e1281f099b7aff

TODO:

  • Add JavaDoc
  • remove test plugin code
  • comment paper-server-generator
  • figure out how to get teams working with real teams, client side ones worked in my fork Non issue just use the Entity#getName() instead of the Entity#getScoreboardEntryName()
  • Persist and load DisguiseData to avoid client disconnects when moving away and approaching again. see disguise api #10478 (comment)

@yannicklamprecht yannicklamprecht force-pushed the feature/disguise-api branch 4 times, most recently from ce89b24 to 9c2de57 Compare April 29, 2024 18:56
patches/api/0475-add-disguise-api.patch Outdated Show resolved Hide resolved
patches/api/0475-add-disguise-api.patch Outdated Show resolved Hide resolved
@kashike kashike added the type: feature Request for a new Feature. label Apr 29, 2024
@yannicklamprecht yannicklamprecht force-pushed the feature/disguise-api branch 11 times, most recently from 0271101 to d38b35d Compare May 4, 2024 13:00
@yannicklamprecht yannicklamprecht force-pushed the feature/disguise-api branch 4 times, most recently from cf41890 to 9d0fd05 Compare May 4, 2024 14:05
@yannicklamprecht
Copy link
Contributor Author

Tested with:
https://gist.github.com/yannicklamprecht/639acba127a54f5617e1281f099b7aff

Only open part is the discussion for a common generator module

@yannicklamprecht yannicklamprecht marked this pull request as ready for review May 4, 2024 14:31
@yannicklamprecht yannicklamprecht requested a review from a team as a code owner May 4, 2024 14:31
@yannicklamprecht
Copy link
Contributor Author

We should probably move the common generator classes into a separate module to reduce duplications.

@MiniDigger
Copy link
Member

this is complicated enough that we prolly want a lil docs page with an example, but that can wait till after its merged and we know the final api design

@yannicklamprecht
Copy link
Contributor Author

yannicklamprecht commented May 4, 2024

this is complicated enough that we prolly want a lil docs page with an example, but that can wait till after its merged and we know the final api design

Thought of adding a Java 18+ snippet to the javadoc but a docs page will be better.

EDIT: Or do you mean regarding code generation?

@yannicklamprecht yannicklamprecht force-pushed the feature/disguise-api branch 2 times, most recently from 44e49f3 to 3bde094 Compare May 4, 2024 20:11
@MiniDigger
Copy link
Member

I meant the api itself

@yannicklamprecht yannicklamprecht force-pushed the feature/disguise-api branch 4 times, most recently from 14578a4 to c69f0fc Compare May 10, 2024 17:42
@yannicklamprecht
Copy link
Contributor Author

Addressed issue with experience orbs by filtering them out. Mentioned that exclusion in the JavaDoc.

Additionally found an issue with ElderGuardian when disguising them as a Player on the client side. That happens only when the ElderGuardian is in the water. First thought is the ElderGuardian stream sucking health from other entities. To be sure I need to deobf the client stacktrace.

Failed to handle packet adm@395c0068
java.lang.ClassCastException: class gct cannot be cast to class ckb (gct and ckb are in unnamed module of loader 'app')
	at fxy.a(SourceFile:1068)
	at adm.a(SourceFile:41)
	at adm.a(SourceFile:13)
	at zz.a(SourceFile:25)
	at bpm.d(SourceFile:162)
	at bpq.d(SourceFile:23)
	at bpm.A(SourceFile:136)
	at bpm.bA(SourceFile:121)
	at ffh.c(SourceFile:1275)
	at ffh.f(SourceFile:888)
	at net.minecraft.client.main.Main.main(SourceFile:265)

@kennytv
Copy link
Member

kennytv commented May 10, 2024

That's ClientPacketListener handleEntityEvent, Player can't be cast to Guardian

@yannicklamprecht
Copy link
Contributor Author

That's ClientPacketListener handleEntityEvent, Player can't be cast to Guardian

Found the reason why. I basically moved away from the entity, the chunk or at least the entities got unloaded.
Due to the state that the disguise data is not persisted on the entity, when loading the entity again it published itself to the client without the disguise info. The client knows the entity uuid only as the disguised type but gets the original one.

I updated the test plugin snippet to reflect the needed change - cache cleaning on death excluded.

It would be way better to persist the disguise data in NBT to avoid manual caching per plugin.

@yannicklamprecht yannicklamprecht force-pushed the feature/disguise-api branch 3 times, most recently from 784c03e to 0f0d912 Compare May 11, 2024 23:42
and generate maps to allow entity metadata syncher validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Request for a new Feature.
Projects
Status: Awaiting review
Development

Successfully merging this pull request may close these issues.

None yet

4 participants