From ad7ad1ed11abb24d2c431811e8faed6672aaebe5 Mon Sep 17 00:00:00 2001 From: Treetrain1 Date: Sun, 19 Nov 2023 17:34:22 -0600 Subject: [PATCH] fix effect advancements --- .../misc/mod_compat/FrozenLibIntegration.java | 25 +++++++++++++------ src/main/resources/wilderwild.accesswidener | 5 ++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/frozenblock/wilderwild/misc/mod_compat/FrozenLibIntegration.java b/src/main/java/net/frozenblock/wilderwild/misc/mod_compat/FrozenLibIntegration.java index 0809789ea4..937b18998d 100644 --- a/src/main/java/net/frozenblock/wilderwild/misc/mod_compat/FrozenLibIntegration.java +++ b/src/main/java/net/frozenblock/wilderwild/misc/mod_compat/FrozenLibIntegration.java @@ -18,6 +18,8 @@ package net.frozenblock.wilderwild.misc.mod_compat; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -66,9 +68,13 @@ import net.minecraft.advancements.critereon.MobEffectsPredicate; import net.minecraft.advancements.critereon.PlayerTrigger; import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; +import net.minecraft.world.effect.MobEffect; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.item.InstrumentItem; @@ -268,15 +274,18 @@ public boolean test(LivingEntity entity) { }}) ); } - case "minecraft:nether/all_potions", "minecraft:nether/all_effects" -> - AdvancementAPI.addCriteria( - advancement, - "wilderwild:reach_boost", - EffectsChangedTrigger.TriggerInstance.hasEffects( - MobEffectsPredicate.Builder.effects() - .and(RegisterMobEffects.REACH) - ) + case "minecraft:nether/all_potions", "minecraft:nether/all_effects" -> { + Criterion criterion = (Criterion) advancement.criteria().get("all_effects"); + MobEffectsPredicate predicate = criterion.triggerInstance().effects.orElseThrow(); + Map, MobEffectsPredicate.MobEffectInstancePredicate> map = new HashMap<>(predicate.effectMap); + map.put( + BuiltInRegistries.MOB_EFFECT.getHolderOrThrow( + BuiltInRegistries.MOB_EFFECT.getResourceKey(RegisterMobEffects.REACH).orElseThrow() + ), + new MobEffectsPredicate.MobEffectInstancePredicate() ); + predicate.effectMap = map; + } default -> {} } diff --git a/src/main/resources/wilderwild.accesswidener b/src/main/resources/wilderwild.accesswidener index 8af65f9e80..5760bc4c30 100644 --- a/src/main/resources/wilderwild.accesswidener +++ b/src/main/resources/wilderwild.accesswidener @@ -1,5 +1,10 @@ accessWidener v2 named +# Advancement +accessible field net/minecraft/advancements/critereon/EffectsChangedTrigger$TriggerInstance effects Ljava/util/Optional; +accessible field net/minecraft/advancements/critereon/MobEffectsPredicate effectMap Ljava/util/Map; +mutable field net/minecraft/advancements/critereon/MobEffectsPredicate effectMap Ljava/util/Map; + # Sculk Spreading accessible class net/minecraft/world/level/block/SculkVeinBlock$SculkVeinSpreaderConfig