Dimension Bootstrap Registry
The BootstrapDimensionRegistry allows you to register dimension types during the bootstrap phase of the Minecraft server lifecycle, which occurs before the server fully initializes.
This can be useful for adding dimension types that need to be available early in the server’s startup process, ensuring that your dimension types are always registered and loaded before any code executes that may reference them — for example, worlds created at startup whose level stems point at a custom dimension type.
Choosing a Composer
Section titled “Choosing a Composer”When registering Dimensions through the BootstrapDimensionRegistry API,
you must choose a Composer to determine how the server will recognize your dimension types.
INJECTOR: Injects dimension types directly into the live Minecraft dimension_type registry by patching Paper’s registry bootstrap process.DATAPACK: Dimension types registered with this composer will be added to the server as if they were registered through a datapack.
Example Usage
Section titled “Example Usage”import io.papermc.paper.plugin.bootstrap.BootstrapContext;
import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
import dev.wyck.model.level.dimension.Dimension;
import dev.wyck.keys.ResourceKey;
import dev.wyck.registry.bootstrap.BootstrapDimensionRegistry;
import dev.wyck.registry.bootstrap.Composer;
import dev.wyck.wrapper.environment.BedRule;
import dev.wyck.wrapper.environment.attribute.EnvironmentAttributes;
import dev.wyck.wrapper.level.dimension.Skybox;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
public class ExampleBootstrapper implements PluginBootstrap {
@Override
public void bootstrap(BootstrapContext context) {
// Registering 2 custom dimension types during the bootstrap phase as if they were in a datapack.
BootstrapDimensionRegistry registry = BootstrapDimensionRegistry.compose(context, Composer.DATAPACK);
// #queue(Dimension) queues this dimension type for registration.
registry.queue(Dimension.builder()
.resourceKey(ResourceKey.of("test", "a"))
.coordinateScale(8.0D)
.minY(0)
.height(256)
.skybox(Skybox.NETHER)
.hasCeiling(true)
.ambientLight(0.1F)
.build()
);
registry.queue(Dimension.builder()
.resourceKey(ResourceKey.of("test", "b"))
.hasFixedTime(true)
.skybox(Skybox.END)
.attribute(EnvironmentAttributes.BED_RULE, BedRule.builder()
.setErrorMessage(Component.text("No sleeping!").color(NamedTextColor.RED))
.setCanSleep(BedRule.Rule.NEVER)
.setCanSetSpawn(BedRule.Rule.WHEN_DARK)
.build()
)
.build()
);
context.getLogger().info("Finished registering dimension types.");
}
}