From 4df5f443a067be067813d730f26530e5c0f8dfbd Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Sun, 6 Nov 2022 23:18:09 -0500 Subject: [PATCH] media cube no longer lies about granting all knowledge --- .../items/magic/ItemCreativeUnlocker.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemCreativeUnlocker.java b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemCreativeUnlocker.java index 1c4ff800..ef31ec94 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemCreativeUnlocker.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/items/magic/ItemCreativeUnlocker.java @@ -5,6 +5,7 @@ import at.petrak.hexcasting.api.item.MediaHolderItem; import at.petrak.hexcasting.api.misc.DiscoveryHandlers; import at.petrak.hexcasting.api.misc.MediaConstants; import at.petrak.hexcasting.api.utils.NBTHelper; +import at.petrak.hexcasting.common.items.ItemLoreFragment; import at.petrak.hexcasting.common.lib.HexItems; import at.petrak.hexcasting.common.lib.HexSounds; import net.minecraft.ChatFormatting; @@ -214,19 +215,23 @@ public class ItemCreativeUnlocker extends Item implements MediaHolderItem { @Override public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity consumer) { if (level instanceof ServerLevel slevel && consumer instanceof ServerPlayer player) { - var rootAdv = slevel.getServer().getAdvancements().getAdvancement(modLoc("root")); - if (rootAdv != null) { - var children = new ArrayList(); - children.add(rootAdv); - addChildren(rootAdv, children); + var names = new ArrayList<>(ItemLoreFragment.NAMES); + names.add(0, modLoc("root")); + for (var name : names) { + var rootAdv = slevel.getServer().getAdvancements().getAdvancement(name); + if (rootAdv != null) { + var children = new ArrayList(); + children.add(rootAdv); + addChildren(rootAdv, children); - var adman = player.getAdvancements(); + var adman = player.getAdvancements(); - for (var kid : children) { - var progress = adman.getOrStartProgress(kid); - if (!progress.isDone()) { - for (String crit : progress.getRemainingCriteria()) { - adman.award(kid, crit); + for (var kid : children) { + var progress = adman.getOrStartProgress(kid); + if (!progress.isDone()) { + for (String crit : progress.getRemainingCriteria()) { + adman.award(kid, crit); + } } } }