Search in sources :

Example 1 with LootTableLoadEvent

use of net.minecraftforge.event.LootTableLoadEvent in project blueprint by team-abnormals.

the class LootModificationManager method apply.

@Override
protected void apply(Map<ResourceLocation, JsonElement> map, ResourceManager resourceManager, ProfilerFiller profiler) {
    this.reset();
    SelectionSpace unmodifiedTables = this.getUnmodifiedEntries();
    for (Map.Entry<ResourceLocation, JsonElement> entry : map.entrySet()) {
        ResourceLocation resourcelocation = entry.getKey();
        if (resourcelocation.getPath().startsWith("_"))
            continue;
        try {
            TargetedModifier<LootTableLoadEvent, Gson, Pair<Gson, PredicateManager>> targetedModifier = TargetedModifier.deserialize(entry.getValue().getAsJsonObject(), Pair.of(GSON, this.lootPredicateManager), LootModifiers.REGISTRY);
            this.addModifiers(targetedModifier.getTargetSelector().getTargetNames(unmodifiedTables), targetedModifier.getPriority(), targetedModifier.getConfiguredModifiers());
        } catch (IllegalArgumentException | JsonParseException jsonparseexception) {
            Blueprint.LOGGER.error("Parsing error loading Loot Modifier: {}", resourcelocation, jsonparseexception);
        }
    }
    Blueprint.LOGGER.info("Loot Modification Manager has assigned {} sets of modifiers", this.size());
}
Also used : SelectionSpace(com.teamabnormals.blueprint.core.util.modification.targeting.SelectionSpace) LootTableLoadEvent(net.minecraftforge.event.LootTableLoadEvent) JsonElement(com.google.gson.JsonElement) ResourceLocation(net.minecraft.resources.ResourceLocation) Gson(com.google.gson.Gson) JsonParseException(com.google.gson.JsonParseException) Map(java.util.Map) Pair(com.mojang.datafixers.util.Pair)

Aggregations

Gson (com.google.gson.Gson)1 JsonElement (com.google.gson.JsonElement)1 JsonParseException (com.google.gson.JsonParseException)1 Pair (com.mojang.datafixers.util.Pair)1 SelectionSpace (com.teamabnormals.blueprint.core.util.modification.targeting.SelectionSpace)1 Map (java.util.Map)1 ResourceLocation (net.minecraft.resources.ResourceLocation)1 LootTableLoadEvent (net.minecraftforge.event.LootTableLoadEvent)1