Skip to content

Conversation

@Hugman76
Copy link
Contributor

@Hugman76 Hugman76 commented Dec 24, 2025

This pull request introduces a new API to facilitate the modification of dimension environment attributes, which are natively immutable.

Rationale

Since the introduction of environment attributes, several use cases have emerged requiring modifications at the dimension level. Currently, applying an attribute across an entire dimension requires iterating through and modifying every individual biome within that dimension using the Biomes Modification API.

This event provides a direct interface for interacting with dimensions attributes. Furthermore, it allows datapack and modpack creators to maintain granular control, as dimension-level modifications are designed with lower priority than biome-specific definitions during attribute evaluation in vanilla.

Usage Example

DimensionEvents.MODIFY_ATTRIBUTES.register((dimension, attributes, registries) -> {
  if (dimension.is(BuiltinDimensionTypes.OVERWORLD)) {
    attributes.set(EnvironmentAttributes.CLOUD_COLOR, PURPLE);
  }
});

@sylv256 sylv256 added the enhancement New feature or request label Dec 28, 2025
Copy link
Contributor

@maityyy maityyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a useful API that we should definitely have, but I'm sure all we need is something like EnchantmentEvents or LootTableEvents, copying the Biome Modification API design is completely unnecessary, confuses users and inflates the code base too much

@Hugman76 Hugman76 force-pushed the ft/dimensions-modifications branch from b1c2eee to 2bded09 Compare January 5, 2026 15:43
@Hugman76 Hugman76 changed the base branch from 1.21.11 to 26.1 January 5, 2026 15:43
@Hugman76 Hugman76 force-pushed the ft/dimensions-modifications branch from 2bded09 to 6e1c7ca Compare January 5, 2026 21:03
@Hugman76 Hugman76 changed the title Dimension Modifications API Add an event to modify dimension environment attributes Jan 5, 2026
@Hugman76
Copy link
Contributor Author

Hugman76 commented Jan 6, 2026

Thanks a lot for the feedback @maityyy, I fully agreed with your points and have almost nothing to add really. I've gone back and remade the whole thing from the ground up using events.

I have to note that modifying attributes using ServerLifecycleEvents.SERVER_STARTED seems to only modify dimensions after they've been baked into the levels. I suppose this means at some point the level and dimension are unsynced. This results in this very same event not being able to fetch the modified attributes (as tested in FabricDimensionTest.)

Therefore, I used ServerLifecycleEvents.SERVER_STARTING to fire the attribute modifications.

I've updated the PR's title and description accordingly.

Comment on lines 84 to 88
stopwatch.stop();

if (dimensionsProcessed > 0) {
LOGGER.info("Applied modifications to {} of {} dimensions in {}", dimensionsChanged, dimensionsProcessed, stopwatch);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the stopwatch needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not, it's a leftover from the PR author's initial attempt to copy the Biome Modification API design. BMAPI uses Stopwatch probably because of the logic of sorting modifications

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I imagined so. I dont think its really that useful in biome modficiation either tbh.

Comment on lines +37 to +39
if (dimensionsModified) {
throw new IllegalStateException("Dimensions in this dynamic registries instance have already been modified");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Is this the only use for the dimensionsModified boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! This is meant to prevent any accidental double-modification, but that should never occur

Comment on lines +52 to +53
ServerLevel overworld = server.getLevel(Level.OVERWORLD);
overworld.setDayTime(6000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Is this needed to get the color? If so a game test would likely be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that's needed. I don't understand how the MODIFY_ATTRIBUTES can be fired in the game test environment though.

Comment on lines 57 to 58
// Build a list of all dimension keys in ascending order of their raw-id to get a consistent result in case
// someone does something stupid.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stupid such as? Doing this sorting will likely hide mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from previous iteration. I figured I'd leave this comment from BMAPI since it makes debugging easier if someone messes up badly.


if (dimensionsProcessed > 0) {
LOGGER.info("Applied modifications to {} of {} dimensions in {}", dimensionsChanged, dimensionsProcessed, stopwatch);
LOGGER.info("Applied modifications to {} of {} dimensions", dimensionsChanged, dimensionsProcessed);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging is not necessary, please remove

@Hugman76 Hugman76 requested review from maityyy and modmuss50 January 9, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants