#Blockbench 5.0 Plugin API Changes

191 messages · Page 1 of 1 (latest)

woven barn
#

Hey <@&341239825770479616>!
The beta for Blockbench 5.0 has just launched, and the update contains several changes that are potentially breaking changes for some plugins.
I have written this article as a guide on how to upgrade your plugins: https://www.blockbench.net/wiki/docs/plugin-upgrade-to-5.0
I'm still expecting 80% of plugins to continue working without any changes, but I would recommend to test your plugins on the latest beta to ensure they are compatible.

Beta: https://github.com/JannisX11/blockbench/releases/tag/v5.0.0-beta.1

Use this thread if you have any questions!

ivory fulcrum
#

@woven barn I should probably have that plugin creator role lol

#

I can't find how to get it

woven barn
#

There you go, you have it now

gray thorn
#

If we're giving them away 🥺
(Or do I have to wait until it's published?)

woven barn
# ivory fulcrum <@137288731731296257> I should probably have that plugin creator role lol

I was going to message you separately anyway, because I think you're mainly gonna be affected by the animation axis changes.
I know the Geckolib uses parts of the bedrock animation export code, so not sure if the part that inverts the values is included in the plugin, but if it is the values need to be inverted on export and on import:

let flipArray = array => {
    if (channel == 'position') {
        array[0] = invertMolang(array[0]);
    }
    if (channel == 'rotation') {
        array[0] = invertMolang(array[0]);
        array[1] = invertMolang(array[1]);
    }
    return array;
}
ivory fulcrum
#

ah ok I'll note that then

#

since you're in beta anyway

#

when I go to look at this I'll see if I can re-find that longstanding export bug blockbench has so we can hopefully get it fixed

worldly sail
#

All of my plugins broke, but the first PR to fix one is up now 🙂

ashen shoal
#

AJ is cooked, lmao

worldly sail
#

Is there any way to have two instances of Blockbench runnning at a time? I'd like to be able to test 4.12.6 and 5.0-beta1 at the same time

steady hawk
#

download portable version

worldly sail
#

Oh wow that works, why doesn't running it with npm run dev work then smh

#

nvm I don't think that works either, when I run the 5.0 portable exe it opens as 4.12.6 like my main install

candid fossil
#

You could open 5.0 in the browser

steady hawk
#

portable suppose to run

worldly sail
#

It runs, just on the wrong version

worldly sail
steady hawk
#

it's the right version, I think they forgot to change the number in the front screen

#

if you check the version in help, about

worldly sail
#

Also says 4.12.6, and it doesn't have any of the new features

#

When I close the other instance of blockbench it opens as 5.0 just fine

#

The same thing happens in reverse if I open the portable first and then my local install

#

Whichever version is opened first is the only one it will open as

steady hawk
#

ah you are right

worldly sail
#

Just to confirm, theres now no way too use native apis that require permission from within the devtools console right?

willow surge
worldly sail
#

both require and requireNativeModule aren't available from the console

#

not as globals at least

ashen shoal
#
worldly sail
#

Thats awesome ill try it out!

ashen shoal
#

Definitely send me feedback when you do! I've only had friends use it as far as I'm aware

ivory fulcrum
#

hey uh..

#

could we get custom keyframe interpolation types back?

#

they've been reduced to a strict set

#

they used to allow custom string values

ivory fulcrum
#

or alternatively a place for custom data on keyframes

ashen shoal
#

Best solution would be some way to define custom interpolation types

#

And have the animator know how to use them

ivory fulcrum
#

I've resorted to just extending the type shrug

#

I was using a custom interpolation type

#

but whatever lol

worldly sail
#

Any chance we could get THREE.GLTFLoader imported by default? It's technically already in as a package since threejs contains it by default now, but it's hard to get hold of it

woven barn
#

How is everyone doing with testing and updating plugins? Any major issues you've run into? Or all good?

worldly sail
#

I wasn't able to test my new gltf one bc file import dialogs were broken, but I haven't looked if that got fixed in a while

woven barn
#

Yeah that was fixed in the second beta

marsh niche
#

ohno I messed up the screenshot.
Just remembered that I had an issue with a plugin breaking saving entirely.
Fortunately I noticed at around 1am when I wanted to quit and noticed the file missing.
Seems like messed up the screenshot for the error log though

#

Can't replicate t right now, but it has been the tint preview plugin from MrCrayfish.

marsh niche
#

Was able to reproduce, actually can't even open some models with the plugin

#
(Plugin):tint_preview.js:577 Uncaught ReferenceError: ProjectData is not defined
    at Array.loadProjectEvent ((Plugin):tint_preview.js:577:4)
    at Object.dispatchEvent (bundle.js:3360:59751)
    at S1.parse (bundle.js:6348:8080)
    at S1.load (bundle.js:6348:2240)
    at r (bundle.js:6111:1773)
    at lP (bundle.js:6111:1963)
    at bundle.js:6111:1140
    at Array.forEach (<anonymous>)
    at Object.cb (bundle.js:6111:1128)
    at bundle.js:3335:59912
woven barn
#

Ah, thanks for reporting

ashen shoal
spiral wren
#

Ill look into it rq.

ashen shoal
#

Is buffer particularly dangerous? Seems like a useful library to have access to even if it can be removed from MC-Build.

spiral wren
#

@ashen shoal let's talk about this related to mc-build in dms

ashen shoal
# ashen shoal Animated Java can't function without the "buffer" library, which is currently un...

Looks like this can be solved on the AJ end if needed, but ideally, any time a plugin requires the buffer library, they should receive a reference to the globalThis.Buffer library that Blockbench already includes in the global scope.

It's already accessible by plugins via the global scope of course, but any time a plugin has a dependency that requires it, that plugin will either have to modify the dependency, or implement some form of build tool script to correctly point the require towards the global value.

ashen shoal
ashen shoal
#

I can't use fflate because it requires the 'module' node module

#

The http and tty modules are unavailable.

#

process not being defined breaks a lot of node modules.

ashen shoal
#

Being unable to access process.env prevents me from including path variable resolution in my plugins.
e.g. turning %USERFOLDER% into D:\Users\Snave.

Animated Java specifically does this for all Blueprint folder / file path settings.

woven barn
ashen shoal
#

That screenshot is of fflates' release code, so I'm not sure. I made sure to import fflate/browser, and I tried both fflate and fflate/browser and both had the same issue. Checking their source also confirms that they both use createRequire

woven barn
#

I think module is a constant that's exposed when a Javascript file is loaded as a module, which is not how plugins are loaded, they are evaluated directly using new Function()()

#

So maybe the bundler needs to be instructed to not package as a module

#

Not sure

ashen shoal
#

I don't think import { createRequire } from 'module' has much to do with the module global

woven barn
#

Is it converted to require('module')?

ashen shoal
#

Hmm, probably.

#

Otherwise it wouldn't even be triggering the require warning right?

#

Interesting, looks like something was wrong before, because it's no longer attempting to require 'module' in my bundle

#

I haven't changed anything though bruh

woven barn
#

yeah, no idea

ashen shoal
woven barn
ashen shoal
#

I believe it's a very old library for reading from and writing to stdout and stdin in terminals. I'm not sure why the download module wants it.

#

I'm getting rid of download anyway. I'll just remove the downloading progress bar, since that's the only reason I wanted something other than fetch.

willow surge
# ashen shoal

this just allows you to use require within ESM modules

#

you have access to require, you dont need createRequire

ashen shoal
#

Makes sense, but it's not my code.

#

¯_(ツ)_/¯

ashen shoal
ashen shoal
ashen shoal
#

Looks like process is still missing in the latest release

woven barn
#

Here is the new API reference documentation btw: https://web.blockbench.net/docs/
Not perfect yet, but now it's generated from the source code and types directly so it'll be much easier to maintain and more detailed and accurate.

ashen shoal
#

Ah, that causes an issue because the npm modules I use expect the global to exist, they don't import it

#

They just reference process as a global

#

I'll have to probably write an ESBuild plugin that transforms global process references to fix that I think

willow surge
ivory fulcrum
#

lol goddamnit

#

plugin was working perfectly fine all the way up until release

#

then it died

#

sad times

ashen shoal
#

Average dev experience

ivory fulcrum
#

also got users saying that some specific animations are inverted in blockbench5 that weren't in blockbench4.. but only sometimes

#

idk what's going on lol

ashen shoal
#

Prob the y axis inversion

#

Mentioned in the upgrade article

ivory fulcrum
#

I did invert though

#

this is what the original instruction was for inversion

ashen shoal
#

Weird

ivory fulcrum
#

unless it's now changed

#

it's undefined but it's also 0

#

but it's also not undefined

#

thanks js, very cool

ashen shoal
#

What is result?

ivory fulcrum
#

even the panel knows what the result is lol, despite erroring it

ashen shoal
#

So result is 0, and you're trying to access vector which is undefined on 0, and then you're attempting to index that undefined value

ivory fulcrum
#

no

#

result is an object, with vector being an array of ints

#

0 is the 0-indexed entry

ashen shoal
#

Ah, well I did ask what result was

ivory fulcrum
#

ah

#

even the function call itself is valid per console

#

like it knows what it is, it knows how to resolve the function, it knows what the value is

#

but it errors as undefined but also it's 0

#

am confuse

#

also somehow this only broke on release...? lol

ashen shoal
#

What's it's value when you hover over it in the source code view?

ivory fulcrum
ashen shoal
#

Vector specifically

ivory fulcrum
ashen shoal
#

Odd

ivory fulcrum
#

yep

#

it's valid in every way I can find, except when trying to run it on-page

#

also, this code is unchanged, and only died in release 5.0, but not in the betas

ashen shoal
#

Are you paused on the uncaught error?

ivory fulcrum
#

which also makes.. no sense

ivory fulcrum
ashen shoal
#

Try pausing on the error itself

#

It's possible you're ahead of the error?

#

So the value is different

ivory fulcrum
#

it is not

ashen shoal
#

No I mean check the "pause on uncaught errors" button and ignore other breakpoints

ivory fulcrum
#

ah right cus it errors for all circumstances

#

yeah ok that one makes sense

ashen shoal
#

Yeah you want the actual value at the time the error is thrown.

ivory fulcrum
#

yeah

#

now to figure out why tf it has multiple keyframes that are the same keyframe for no reasno

#

also it looks like undo is not working properly at all in the animation pane anymore

ashen shoal
ivory fulcrum
#

what the heck lol

#

imgur blocks you?

ashen shoal
#

Not me, but other users have noticed this issue

#

Generally image hosting websites are blocked in a lot of countries for not complying with their regulations

ivory fulcrum
#

interesting

#

wonder how that'll work when australia blocks github in december thinkies

ashen shoal
#

Well, at least for Animated Java that will break a lot more than just images

ivory fulcrum
#

indeed

ashen shoal
#

AJ gets almost all of it's Minecraft data from a few public github repos

ivory fulcrum
#

no-one's saying it's a good idea lol

#

but we don't have people with good intentions or any kind of knowledge making laws so

#

either way thanks for the heads up

#

we just already have those images in imgur so it's easy to re-use em

#

but I'll migrate the used ones

woven barn
#

Yeah it seems to be blocked for people in the UK at the moment

ashen shoal
#

oof

ivory fulcrum
#

australia next

ivory fulcrum
#

lol @woven barn

#

just can't win

#

enabled the dep note and now this -.-

ashen shoal
#

Update the old one to show a pop-up when installed in 5.0+

ivory fulcrum
#

Lol

woven barn
#

Change the deprecation note to also call it "GeckoLib Models & Animations"

ivory fulcrum
#

yeah..