Skip to content

FTBTeam/FTB-Team-Dimensions

Repository files navigation

FTB Team Dimensions

Overview

This is a companion mod for FTB modpacks which add team-based dimensions, and not intended for general usage in most packs.

FTB Team Dimensions allows dimensions to be dynamically created for teams (FTB Teams is a required dependency). Players join the overworld in a prebuilt lobby structure with a portal, and on entering the portal get the option to choose from one or more "island" structures in a new dimension which will be created for their team. The party team will be auto-created if it does not exist yet. New players can be invited the team in the usual way, and will be immediately ported to the team's existing dimension upon joining. If a team is disbanded, the dimension is archived, and any players in the dimension are transferred back to the overworld lobby.

Currently, there are two chunk generation types, both for simple void dimensions:

  • Multi-biome generation with an overworld-like biome distribution; this is the default
    • See also the replaceColdBiomesNearSpawn settings, which can be used to replace the biome of chunks near spawn if the biome is a cold one; cold biomes mess with exposed water blocks and cover everything with snow.
  • Single biome generation; set singleBiomeDimension in mod config to true to enforce a single biome for the entire dimension.
    • You can override the biome that is used via the singleBiomeName config setting (default is minecraft:the_void)

More flexibility is planned in terms of types of world-gen in the future.

Configuration

Some basic familiarity with 1.19.2 data-driven world generation is required here.

Nearly all configuration is done via datapack, in particular the vanilla structure and structure_set to define the prebuilt "islands" which will be pre-generated in the new dimension (always at the (0,0) chunk). There is also a custom ftbdim_prebuilt_structures datapack type, which defines which structures are available to the player (when the player first enters the lobby portal, one entry per ftbdim_prebuilt_structures entry will be shown in the GUI).

The default prebuilt structure (data/ftbteamdimensions/ftbdim_prebuilt_structures/island1.json) looks something like this (with optional fields not necessarily included in the actual file):

{
  "id": "ftbteamdimensions:island1",
  "structure": "ftbteamdimensions:spawn/island1",
  "name": "Simple Island",
  // optional fields below here, with their defaults
  "author": "FTB Team",
  "structure_set": "ftbteamdimensions:default",
  "height": 64,
  "dimension_type": "ftbteamdimensions:default",
  "preview_image": "ftbteamdimensions:textures/spawn/island1.png",
  "spawn_override": [ 0, 64, 0 ],
  "display_order": 0
}
  • "id" field is mandatory, unique, and should correspond to the JSON filename
  • "structure" field is mandatory and determines the NBT structure file which will be used
    • See data/ftbteamdimensions/structures/spawn/island1.nbt for the default island, which is a tiny island of grass and dirt
  • "name" field is mandatory and is the name displayed in the player's GUI when selecting a structure
    • This can be a literal string or a translation key
  • "author" field is optional and defaults to "FTB Team" - displayed as "by " in the player's GUI when selecting a structure
    • this is a literal string
  • "structure_set" field is optional and is the structure set tag to use
    • Defaults to ftbteamdimensions:default, which includes only the structure set ftbteamdimensions:start
    • This controls which structure set(s) will be used for the island during generation of the dimension
    • It's unlikely you'll need to change this.
  • "height" is optional, and controls the absolute Y-level at which spawn islands are generated.
    • Defaults to 64. TODO support for surface-relative Y values.
  • "dimension_type" is optional, and determines the dimension type used for created dimensions
    • Defaults to ftbteamdimensions:default, an overworld-like dimension type
  • "preview_image" is optional, and points to a texture (which should be 128x64) to be shown in the structure selection GUI; typically a screenshot of the structure, but could be any image
    • Default texture for <modname>:<id> is <modname>:textures/spawn/<id>.png
  • "spawn_override" is optional, and can be used to spawn the player at a non-default position
    • Default position is (0, HEIGHT, 0), where HEIGHT is the island Y-level (see "height" above)
  • "display_order" is optional, a simple numeric value which affects the order in which islands are shown in the GUI when players enter the portal
    • Islands of the same display order are sorted alphabetically by the display name

Structure NBT

Structure files (both for the overworld lobby and dimension island structures) are standard vanilla NBT structures, as saved via Structure Blocks. There is one important requirement: all structures must contain one Structure Block in data mode with the custom data tag spawn_point. This is used to determine where players will spawn in both the overworld lobby and in team dimensions that are created.

Structures created will always be positioned with the spawn_point block at (X,Y,Z) = (0,H,0), where H = the "height" field from the prebuilt structure JSON above. The data structure block is replaced with air when the structure is actually placed into the world, and the player will spawn with their feet in this block by default (but see the "spawn_override" field above).

The default overworld lobby structure is at data/ftbteamdimensions/structures/lobby.nbt, but this can be changed in one of two ways:

  • in mod config (see lobbyStructure in ftbteamdimensions-common.toml)
  • or simply overwrite it via datapack!

Dimension Pre-gen

Creating dimensions on the fly can be an expensive operation, and that can cause problems on a live server, with players potentially experiencing significant lag. To mitigate this, a method has been added to pre-generate dimensions where possible, by copying in a known set of region (or entity or POI) MCA files from a template directory into the live dimension directory just before the dimension is created. In that way, the server sees existing MCA files for the initial regions and can skip CPU-expensive worldgen for them.

This feature works well for void dimensions, and for non-void dimension where the terrain is predictable, i.e. using a fixed seed. It's not suitable for dimensions where terrain generation can't be easily predicted.

To set up pre-gen for a dimension:

  • Take the MCA files from a newly-generated dynamic dimension; you must include the region/*.mca files at a minimum, and optionally also any entities/*.mca and poi/*.mca files
  • Take the prebuilt ID for the dynamic dimension, which is the id field from the ftbdim_prebuilt_structures JSON file described above
  • Turn this resource location into a directory path, e.g. ftbteamdimensions:island1 becomes ftbteamdimensions/island1
  • Copy these files into <instance-dir>/ftbteamdimensions/pregen/<path> where <path> is the path you got in the last step, and <instance-dir> is the root-level directory for your game instance, i.e. the directory where your world/ directory lives.

For the ftbteamdimensions:island1 example, you should have something like:

$ ls
banned-ips.json      config         defaultconfigs  ftbteamdimensions  mods      options.txt    resources  screenshots        usercache.json      whitelist.json
banned-players.json  crash-reports  eula.txt        logs               ops.json  resourcepacks  saves      server.properties  usernamecache.json  world

$ ls -R ftbteamdimensions
ftbteamdimensions:
pregen

ftbteamdimensions/pregen:
ftbteamdimensions

ftbteamdimensions/pregen/ftbteamdimensions:
island1

ftbteamdimensions/pregen/ftbteamdimensions/island1:
region

ftbteamdimensions/pregen/ftbteamdimensions/island1/region:
r.0.0.mca   r.0.1.mca   r.-1.0.mca  r.-1.-1.mca  r.1.-1.mca  r.-1.-2.mca  r.-2.0.mca   r.-2.1.mca
r.0.-1.mca  r.0.-2.mca  r.1.0.mca   r.-1.1.mca   r.1.1.mca   r.1.-2.mca   r.-2.-1.mca  r.-2.-2.mca

Right before a dynamic dimension is created, the mod will check for the existence of this directory, and if it exists for the prebuilt structure ID being used, will copy those files across to <instance>/world/dimensions/ftbteamdimensions/team/<UUID>.