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

Implement client behaviour packs #1879

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

DasEtwas
Copy link

@DasEtwas DasEtwas commented Aug 4, 2021

Overview

  • This PR enables the downloading of behavior packs.
  • It adds a new directory client_behavior_packs in the data folder.
  • Resource Packs belong in resource_packs as before, and Behavior Packs belong in client_behavior_packs
  • The server now checks if a pack is of the right type for the folder it is in by checking metadata.json:modules[n].type
  • For setting the scripting flag in the resource data info packet, the server now reads the zip's entry list and sets this flag to true is a file ending with .js was found

Motivation

  • Client-side behavior packs for normal minecraft worlds can now be used
  • By enabling the use of client-side behavior packs, plugin developers can now enhance their plugins using ScriptCustomEventPacket etc. to trigger client-side JavaScript (on Win10, where scripts are supported).

Testing

This PR was tested to work in the following cases (meaning players could join and download and display the packs):

  • One resource pack loaded
  • One behavior pack loaded
  • One resource pack and behavior pack loaded
    (tested on android and win)

furthermore:

  • requiresScripts() was tested to work by placing a .js file in a behavior pack

Problems

  • The newly added errors don't seem to print correctly, they print the translation keys instead, at least in my build. Submodules were cloned.

New language keys

nukkit.resources.unsupported-module-type
nukkit.resources.invalid-type-resource
nukkit.resources.invalid-type-behavior
nukkit.resources.loaded-resource-pack
nukkit.resources.loaded-behavior-pack

Further ideas

It may make sense to check if a client supports scripting, and if not, set scripting to false in the resource info packet.

@DasEtwas
Copy link
Author

DasEtwas commented Aug 4, 2021

Please excuse @belohnung 's commits, they don't seem to affect my diff.

DasEtwas added a commit to DasEtwas/Languages that referenced this pull request Aug 4, 2021
Adds language keys used by CloudburstMC/Nukkit#1879
@PetteriM1
Copy link
Member

Do you have an example behavior pack this can be tested with? Also maybe it could be a good idea to bump the API version.

@DasEtwas
Copy link
Author

Not one to post here.

@ghost
Copy link

ghost commented Apr 11, 2022

Behaviour packs is applies by client? I can create behaviour pack with changed stack size of, e.x. golden apple and it can be work?

@belohnung
Copy link

Behaviour packs is applies by client? I can create behaviour pack with changed stack size of, e.x. golden apple and it can be work?

This only supports client features and doesn't affect server logic.

@snaildos
Copy link

Is this still maintained or going to be tested?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants