FIXME In versions 1.16 and beyond, dimensions can be defined in data packs: More information about custom dimensions via JSON can be found in the Minecraft Wikia.

Minecraft 1.16 and later

The information below applies to Minecraft 1.15 and earlier.

However, you must still create a portal using fabric, more information about custom portals here.

An example that also shows some of the fabric-api specific code can be found in the fabric-dimensions-v1 testmod.

Creating a Dimension [WIP] (1.15 and earlier)

Creating your own dimension is an advanced topic. This tutorial assumes you have already read through the previous tutorials on world generation, and have other basic knowledge such as how to create your own blocks.

Creating your DimensionType

The first thing you want to do is register your custom DimensionType. We are going to create a bee dimension.

  1. public class TutorialDimensions {
  2. public static final FabricDimensionType BEE = FabricDimensionType.builder()
  3. .defaultPlacer((oldEntity, destinationWorld, portalDir, horizontalOffset, verticalOffset) -> new BlockPattern.TeleportTarget(new Vec3d(destinationWorld.getTopPosition(Heightmap.Type.WORLD_SURFACE, BlockPos.ORIGIN)), oldEntity.getVelocity(), (int) oldEntity.yaw))
  4. .factory(BeeDimension::new)
  5. .skyLight(false)
  6. .buildAndRegister(new Identifier(TutorialMod.MOD_ID, "bee"));
  7.  
  8. public static void register() {
  9. // load the class
  10. }
  11. }
  1. public class TutorialMod implements ModInitializer {
  2. @Override
  3. public void onInitialize() {
  4. // ...
  5. TutorialDimensions.register();
  6. }
  7. }

The defaultPlacer determines the default placement when an entity is teleported into this dimension. Here we have made it, so the entity spawns on the top block at 0, 0 when entering the dimension. If you want custom portal logic, this is the place to do it. See the EntityPlacer documentation for details.

The Dimension class

  1. public class BeeDimension extends Dimension {
  2. private static final Vec3d FOG_COLOR = new Vec3d(0.54, 0.44, 0.16);
  3.  
  4. public BeeDimension(World world, DimensionType type) {
  5. // The third argument indicates how visually bright light level 0 is, with 0 being no extra brightness and 1 being like night vision.
  6. // The overworld and the end set this to 0, and the Nether sets this to 0.1. We want our dimension to be a bit brighter.
  7. super(world, type, 0.5f);
  8. }
  9.  
  10. @Override
  11. public ChunkGenerator<?> createChunkGenerator() {
  12. // For now, we'll create a superflat world to get a basic dimension working.
  13. // We'll come back and change this later.
  14. FlatChunkGeneratorConfig generatorConfig = FlatChunkGeneratorConfig.getDefaultConfig();
  15. // The biome everywhere will be jungle
  16. FixedBiomeSourceConfig biomeConfig = BiomeSourceType.FIXED.getConfig(world.getLevelProperties()).setBiome(Biomes.JUNGLE);
  17. return ChunkGeneratorType.FLAT.create(world, BiomeSourceType.FIXED.applyConfig(biomeConfig), generatorConfig);
  18. }
  19.  
  20. // The following 2 methods relate to the dimension's spawn point.
  21. // You can return null if you don't want the player to be able to respawn in these dimensions.
  22.  
  23. @Override
  24. public BlockPos getSpawningBlockInChunk(ChunkPos chunkPos, boolean checkMobSpawnValidity) {
  25. return null;
  26. }
  27.  
  28. @Override
  29. public BlockPos getTopSpawningBlockPosition(int x, int z, boolean checkMobSpawnValidity) {
  30. return null;
  31. }
  32.  
  33. @Override
  34. public float getSkyAngle(long worldTime, float tickDelta) {
  35. // Returns a sky angle ranging between 0 and 1.
  36. // This is a very simple implementation that approximates the overworld sky angle, but is easier to understand.
  37. // In the overworld, the sky does not quite move at a constant rate, see the OverworldDimension code for details.
  38. final int dayLength = 24000;
  39. double daysPassed = ((double) worldTime + tickDelta) / dayLength;
  40. return MathHelper.fractionalPart(daysPassed - 0.25);
  41. }
  42.  
  43. @Override
  44. public boolean hasVisibleSky() {
  45. return true;
  46. }
  47.  
  48. // Fog color RGB
  49. @Environment(EnvType.CLIENT)
  50. @Override
  51. public Vec3d getFogColor(float skyAngle, float tickDelta) {
  52. return FOG_COLOR;
  53. }
  54.  
  55. @Override
  56. public boolean canPlayersSleep() {
  57. return false;
  58. }
  59.  
  60. @Environment(EnvType.CLIENT)
  61. @Override
  62. public boolean isFogThick(int x, int z) {
  63. return false;
  64. }
  65.  
  66. @Override
  67. public DimensionType getType() {
  68. return TutorialDimensions.BEE;
  69. }
  70. }

Creating a ChunkGenerator [TODO]

Creating a BiomeSource [TODO]

Creating a SurfaceBuilder [TODO]