Skip to content

Commit

Permalink
fix effect advancements
Browse files Browse the repository at this point in the history
  • Loading branch information
Treetrain1 committed Nov 19, 2023
1 parent 2d4139b commit ad7ad1e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<EffectsChangedTrigger.TriggerInstance> criterion = (Criterion<EffectsChangedTrigger.TriggerInstance>) advancement.criteria().get("all_effects");
MobEffectsPredicate predicate = criterion.triggerInstance().effects.orElseThrow();
Map<Holder<MobEffect>, 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 -> {}
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/wilderwild.accesswidener
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit ad7ad1e

Please sign in to comment.