Search in sources :

Example 1 with RegistryOps

use of net.minecraft.resources.RegistryOps in project blueprint by team-abnormals.

the class ChunkGeneratorModificationManager method apply.

@Override
protected void apply(Map<ResourceLocation, JsonElement> map, ResourceManager resourceManager, ProfilerFiller profilerFiller) {
    RegistryOps<JsonElement> registryOps = this.registryOps;
    int loadedModifiers = 0;
    for (Map.Entry<ResourceLocation, JsonElement> entry : map.entrySet()) {
        try {
            TargetedModifier<ChunkGenerator, RegistryOps<JsonElement>, RegistryOps<JsonElement>> targetedModifier = TargetedModifier.deserialize(entry.getValue().getAsJsonObject(), registryOps, ChunkGeneratorModifiers.REGISTRY);
            this.modifiers.computeIfAbsent(targetedModifier.getPriority(), __ -> new LinkedList<>()).add(targetedModifier);
            loadedModifiers++;
        } catch (IllegalArgumentException | JsonParseException exception) {
            Blueprint.LOGGER.error("Parsing error loading Chunk Generator Modifier: {}", entry.getKey(), exception);
        }
    }
    Blueprint.LOGGER.info("Chunk Generator Modification Manager has loaded {} modifiers", loadedModifiers);
}
Also used : JsonParseException(com.google.gson.JsonParseException) SelectionSpace(com.teamabnormals.blueprint.core.util.modification.targeting.SelectionSpace) ResourceLocation(net.minecraft.resources.ResourceLocation) RegistryOps(net.minecraft.resources.RegistryOps) ProfilerFiller(net.minecraft.util.profiling.ProfilerFiller) EnumMap(java.util.EnumMap) ResourceManager(net.minecraft.server.packs.resources.ResourceManager) HashMap(java.util.HashMap) TargetedModifier(com.teamabnormals.blueprint.core.util.modification.TargetedModifier) AddReloadListenerEvent(net.minecraftforge.event.AddReloadListenerEvent) Blueprint(com.teamabnormals.blueprint.core.Blueprint) ConfiguredModifier(com.teamabnormals.blueprint.core.util.modification.ConfiguredModifier) JsonElement(com.google.gson.JsonElement) ChunkGenerator(net.minecraft.world.level.chunk.ChunkGenerator) MinecraftForge(net.minecraftforge.common.MinecraftForge) SimpleJsonResourceReloadListener(net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener) Gson(com.google.gson.Gson) EventPriority(net.minecraftforge.eventbus.api.EventPriority) Map(java.util.Map) Mod(net.minecraftforge.fml.common.Mod) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent) DataUtil(com.teamabnormals.blueprint.core.util.DataUtil) ServerAboutToStartEvent(net.minecraftforge.event.server.ServerAboutToStartEvent) LinkedList(java.util.LinkedList) RegistryOps(net.minecraft.resources.RegistryOps) JsonParseException(com.google.gson.JsonParseException) Blueprint(com.teamabnormals.blueprint.core.Blueprint) LinkedList(java.util.LinkedList) JsonElement(com.google.gson.JsonElement) ResourceLocation(net.minecraft.resources.ResourceLocation) ChunkGenerator(net.minecraft.world.level.chunk.ChunkGenerator) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Gson (com.google.gson.Gson)1 JsonElement (com.google.gson.JsonElement)1 JsonParseException (com.google.gson.JsonParseException)1 Blueprint (com.teamabnormals.blueprint.core.Blueprint)1 DataUtil (com.teamabnormals.blueprint.core.util.DataUtil)1 ConfiguredModifier (com.teamabnormals.blueprint.core.util.modification.ConfiguredModifier)1 TargetedModifier (com.teamabnormals.blueprint.core.util.modification.TargetedModifier)1 SelectionSpace (com.teamabnormals.blueprint.core.util.modification.targeting.SelectionSpace)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 RegistryOps (net.minecraft.resources.RegistryOps)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 ResourceManager (net.minecraft.server.packs.resources.ResourceManager)1 SimpleJsonResourceReloadListener (net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener)1 ProfilerFiller (net.minecraft.util.profiling.ProfilerFiller)1 ChunkGenerator (net.minecraft.world.level.chunk.ChunkGenerator)1 MinecraftForge (net.minecraftforge.common.MinecraftForge)1 AddReloadListenerEvent (net.minecraftforge.event.AddReloadListenerEvent)1