Nukkit
Nukkit copied to clipboard
Implement client behaviour packs
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 inclient_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 totrue
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.
Please excuse @belohnung 's commits, they don't seem to affect my diff.
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.
Not one to post here.
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?
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.
Is this still maintained or going to be tested?