Search in sources :

Example 1 with NamespacedCategory

use of org.spongepowered.common.config.tracker.NamespacedCategory in project SpongeCommon by SpongePowered.

the class RegistryBackedTrackableBridge method bridge$refreshTrackerStates.

default void bridge$refreshTrackerStates() {
    final ResourceLocation key = this.bridge$trackerRegistryBacking().getKey((T) (Object) this);
    final String namespace = key.getNamespace();
    final String path = key.getPath();
    final NamespacedCategory namespacedCategory = this.bridge$trackerCategory().namespacedOrCreate(namespace);
    final NamespacedCategory.ValueCategory valueCategory = namespacedCategory.valueOrCreate(path);
    if (!namespacedCategory.enabled()) {
        this.bridge$setAllowsBlockBulkCaptures(false);
        this.bridge$setAllowsBlockEventCreation(false);
        this.bridge$setAllowsEntityBulkCaptures(false);
        this.bridge$setAllowsEntityEventCreation(false);
        valueCategory.setAllowBlockEvents(false);
        valueCategory.setAllowEntityEvents(false);
        valueCategory.setCaptureBlocksInBulk(false);
        valueCategory.setCaptureEntitiesInBulk(false);
    } else {
        this.bridge$setAllowsBlockEventCreation(valueCategory.allowsBlockEvents());
        this.bridge$setAllowsEntityEventCreation(valueCategory.allowsEntityEvents());
        this.bridge$setAllowsBlockBulkCaptures(valueCategory.capturesBlocksInBulk());
        this.bridge$setAllowsEntityBulkCaptures(valueCategory.capturesEntitiesInBulk());
    }
    if (namespacedCategory.enabled() && this.bridge$trackerCategory().autoPopulate()) {
        this.bridge$saveTrackerConfig();
    }
}
Also used : NamespacedCategory(org.spongepowered.common.config.tracker.NamespacedCategory) ResourceLocation(net.minecraft.resources.ResourceLocation)

Aggregations

ResourceLocation (net.minecraft.resources.ResourceLocation)1 NamespacedCategory (org.spongepowered.common.config.tracker.NamespacedCategory)1