Skip to content

Creating your first Requirement

WereF0X edited this page Jul 8, 2026 · 3 revisions

To create a new Requirement, firstly you need to make a new class that extendsRequirement.

Let's work together on an example. A Requirement for how many blocks in general the player needs to have broken. This is already present in Access Denied, but it can be an easy example.

  1. The Requirement class
    Let's create a new final class, called for example BlocksBrokenRequirement and make it extend Requirement.

Since it needs to store a certain amount of blocks the player needs to have broken, we add a value to pass in the constructor.

public final class BlocksBrokenRequirement extends Requirement {

    private final int count;

    public BlocksBrokenRequirement(int count) {
        this.count = count;
    }

Now, we can override the methods to let us shape our Requirement to our will. Let's assume you are keeping track on your own way of how many blocks the player has broken. For this example, we'll use an imaginary method player.getBlocksBroken().

    @Override
    public boolean isSatisfied(Player player) {
        return player.getBlocksBroken() >= count;
    }

isSatisfied verifies when the player has completed the Requirement. In this case, when they have broken more blocks than the count provided. If this returns false, the player will be denied access to the dimension.

    @Override
    public Component getMissingMessage(Player player) {
        int missing = count - player.getBlocksBroken();
        return Component.translatable("access_denied.requirement.blocks.broken", missing);
    }

getMissingMessage is a Component that is attached to the message displayed when the player can't enter a dimension due to unmet requirements. It's also shown in the Dimension Requirements page to view which Requirements the player hasn't unlocked yet.

Now let's look at the complete picture.

public final class BlocksBrokenRequirement extends Requirement {

    private final int count;

    public BlocksBrokenRequirement(int count) {
        this.count = count;
    }

    @Override
    public boolean isSatisfied(Player player) {
        return player.getBlocksBroken() >= count;
    }

    @Override
    public Component getMissingMessage(Player player) {
        int missing = count - player.getBlocksBroken();
        return Component.translatable("access_denied.requirement.blocks.broken", missing);
    }
}

You've created your first Requirement! Now let's move on to registering it.

Clone this wiki locally