blockbench
blockbench copied to clipboard
Allow Textures to be created outside of a Project
Animated Java needs to create a texture that isn't related to any specific project, however, the Texture constructor includes this line:
Project.materials[this.uuid] = mat;
which causes an Error if Project
isn't a ModelProject if I attempt to make the Texture before a Project has actually been loaded.
My PR is very simple:
if (!data.standalone) {
if (!Project) throw new Error('Attempted to create a Texture without a Project. If this is intentional, set the standalone option to true.');
Project.materials[this.uuid] = mat;
};
Add an option to TextureOptions to avoid adding to a project, while still throwing an error otherwise, but using that Error to intentionally inform the plugin developer.
My current work-around solution is this extremely hacky bit of code:
const OLD_PROJECT = Project
// @ts-ignore
Project = { materials: {} }
export const TRANSPARENT_TEXTURE = new Texture(
{
id: `${PACKAGE.name}:transparent_texture`,
name: 'Transparent',
},
'797174ae-5c58-4a83-a630-eefd51007c80'
)
Project = OLD_PROJECT
Deploy Preview for blockbench-dev ready!
Name | Link |
---|---|
Latest commit | c991aaed9f54006dbe68456ccc945c720e6061d5 |
Latest deploy log | https://app.netlify.com/sites/blockbench-dev/deploys/662d3bec5231bc00081996da |
Deploy Preview | https://deploy-preview-2303--blockbench-dev.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Closed due to discussion with Jannis on Discord