-
Notifications
You must be signed in to change notification settings - Fork 0
Making a BuilderScreen
Each Requirement must have its own screen, that is automatically built into the Requirements Builder by Access Denied.
The API provides a class you can extend without needing to extend Screen directly. Let's explore its purpose and capabilities.
To make your own, you need to make a class extending BuilderScreen, for example: public final class BuilderBlocksBrokenScreen extends BuilderScreen.
These are the methods you can find useful:
-
applyToContext(BuilderContext context);
This method is what you will be using to set your Requirement values from the BuilderScreen. The BuilderContext keeps track of the what has to be set and is passed to the final screen before being serialized. A good example of this is:
@Override
protected void applyToContext(BuilderContext context) {
context.addRequirement(new BlocksBrokenRequirement(blocksBroken));
}-
public abstract Component validate();
You can use this to verify if everything is correct, like values to set not being null, or invalid, etc. It's automatically called when the user goes to the next page, so you should override this! Should returnnullif everything is correct. If not, you can return an error component to tell the player what is wrong. -
addSkipButton(int x, int y) {}
Lets you add a button to skip the Requirement when using the Builder, at a position of your choice. -
addNextButton(int x, int y) {}
Lets you add a button to go to the next Requirement in the Builder. Automatically callsvalidate()and auto-sets the error. If everything is fine, automatically applies to context (applyToContext(BuilderContext context)). -
setError(Component message) {}
Allows you to set an error to display. -
showError(GuiGraphics guiGraphics, int x, int y) {}
Display the current set error in a position to your liking.
There are two last steps we must do before we are done.