Adding compat as mod dev
Disable team management​
You can use the API to disable team management without needing to change the configuration. Additionally, you can prevent players from being teleported to spawn when joining the world. For more information, visit the SkyblockBuilder API documentation 🔗. This can be called in the main constructor of your mod.
Custom NeoForge Events​
Skyblock Builder triggers several events which you can subscribe to, similar to normal NeoForge events. Here are all the events:
- Create Team
- Invite Player
- Accept Invitation
- Decline Invitation
- Send Join Request
- Accept Join Request
- Deny Join Request
- Toggle Visitation Status
- Toggle Join Request Status
- Add Spawn
- Remove Spawn
- Reset Spawns
- Rename Team
- Leave Team
- Create Team
- Clear Team
- Delete Team
- Add to Team
- Remove from Team
- Teleport Home
- Teleport to Spawn
- Visit Island
- Change Dimension
All events have proper Javadoc documentation explaining their functionality.
Sending Players to the Right Dimension​
This only matters if dimension per team is enabled. With that feature on,
minecraft:overworld and minecraft:the_nether are no longer the same place for everyone - each team has its own copy
of them, so a hardcoded dimension key sends the player into somebody else's world, or into the shared one they left
behind.
If your mod teleports players itself, fire
SkyblockChangeDimensionEvent on the
NeoForge.EVENT_BUS with the dimension you were about to use, then use getDimension() instead. Skyblock Builder
rewrites it to the calling player's team dimension, and leaves it untouched when there is nothing to rewrite.
Skyblock Builder already does this for a few mods itself. Have a look at the coremods module if you want to see how
that is wired up.
Knowing Which Dimension a Player Is Really In​
A team dimension is a copy of a vanilla one, but it does not share its id, so a check like
player.level().dimension() == Level.NETHER fails for every team.
To work around that, Skyblock Builder attaches the normalized dimension to every player. The attachment is registered
as skyblockbuilder:data and stores the vanilla dimension that the player's current one stands in for:
ResourceKey<Level> dimension = player.getData(ModAttachmentTypes.data);
A player standing in their team's own nether reads back minecraft:the_nether, and one on the spawn island reads back
whatever you set as the spawn dimension. It is serialized as
normalized_dimension, survives death, and defaults to minecraft:overworld. Here's an example output:
"skyblockbuilder:data": {normalized_dimension: "minecraft:overworld"}
The attachment is only maintained while dimension per team is enabled, and it is updated when the player changes
dimension. If you just want to map a dimension key to the vanilla one it copies, without going through a player, use
WorldUtil.resolveOriginalDimension(ResourceKey<Level>) instead.