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 +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

@Hugman76 Hugman76 requested review from maityyy and modmuss50 January 9, 2026 21:31
import net.fabricmc.fabric.mixin.dimension.MappedRegistryAccessor;

public class DimensionModificationImpl implements ModInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(DimensionModificationImpl.class);
Copy link
Member

Choose a reason for hiding this comment

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

NIT: LOGGER is never used

@modmuss50 modmuss50 added the status: last call If you care, make yourself heard right away! label Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request status: last call If you care, make yourself heard right away!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants