/* * Copyright (c) Forge Development LLC and contributors * SPDX-License-Identifier: LGPL-2.1-only */ package net.minecraftforge.event; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.datafix.fixes.StructuresBecomeConfiguredFix; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Cancelable; import net.minecraftforge.eventbus.api.Event; import java.util.Locale; import java.util.Map; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; /** * Fired for registering structure conversions for pre-1.18.2 worlds. This is used by {@link StructuresBecomeConfiguredFix} * for converting old structure IDs in pre-1.18.2 worlds to their new equivalents, which can be differentiated per biome. * *
By default, structures whose old ID has a namespace which is not equal to {@value ResourceLocation#DEFAULT_NAMESPACE} * will be assumed to belong to a modded structure and will be used as the new ID. Mods may choose to register structure * conversions for their structures, if they wish to override this default behavior.
* *This event will only fire if {@link StructuresBecomeConfiguredFix} is used, as a result of converting a * pre-1.18.2 world to the current version.
* *This event is not {@linkplain Cancelable cancelable}, and does not {@linkplain HasResult have a result}.
* *This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus}, * only on the {@linkplain net.minecraftforge.fml.LogicalSide#SERVER logical server}.
* * @see StructuresBecomeConfiguredFix * @see #register(String, StructuresBecomeConfiguredFix.Conversion) */ public class RegisterStructureConversionsEvent extends Event { private final MapA structure conversion can be of two kinds:
*If a structure is in a biome which exists in the map, the * structure ID in the corresponding entry is used as the new structure ID. If there is no such biome found, * the new structure ID will be the fallback structure ID.
* *For example, the following registers a biome-mapped conversion for {@code exampleStructure} with the * following logic:
*{@code
* event.register("exampleStructure", StructuresBecomeConfiguredFix.Conversion.biomeMapped(Map.of(
* List.of("minecraft:desert", "minecraft:jungle"), "examplemod:deserted_structure",
* List.of("minecraft:ocean"), "examplemod:flooded_structure"
* ), "examplemod:structure"));
* }
*