Search in sources :

Example 11 with Advancement

use of net.minecraft.advancements.Advancement in project SpongeCommon by SpongePowered.

the class AdvancementTreeRegistryModule method registerAdditionalCatalog.

@SuppressWarnings("unchecked")
@Override
public void registerAdditionalCatalog(AdvancementTree advancementTree) {
    super.register(advancementTree);
    if (INSIDE_REGISTER_EVENT) {
        final Advancement advancement = (Advancement) advancementTree.getRootAdvancement();
        final IMixinAdvancementList advancementList = (IMixinAdvancementList) AdvancementManager.ADVANCEMENT_LIST;
        advancementList.getRootsSet().add(advancement);
        final AdvancementList.Listener listener = advancementList.getListener();
        if (listener != null) {
            listener.rootAdvancementAdded(advancement);
        }
    }
}
Also used : AdvancementList(net.minecraft.advancements.AdvancementList) IMixinAdvancementList(org.spongepowered.common.interfaces.advancement.IMixinAdvancementList) IMixinAdvancementList(org.spongepowered.common.interfaces.advancement.IMixinAdvancementList) Advancement(net.minecraft.advancements.Advancement)

Example 12 with Advancement

use of net.minecraft.advancements.Advancement in project ManaCraft by Yaossg.

the class Util method giveAdvancement.

public static void giveAdvancement(Entity player, String advance) {
    if (player.getServer() != null) {
        MinecraftServer server = player.getServer();
        if (player instanceof EntityPlayerMP) {
            EntityPlayerMP playerMP = (EntityPlayerMP) player;
            Advancement advancement = server.getAdvancementManager().getAdvancement(new ResourceLocation(advance));
            AdvancementProgress progress = playerMP.getAdvancements().getProgress(advancement);
            if (!progress.isDone()) {
                for (String s : progress.getRemaningCriteria()) {
                    playerMP.getAdvancements().grantCriterion(advancement, s);
                }
            }
        }
    }
}
Also used : AdvancementProgress(net.minecraft.advancements.AdvancementProgress) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Advancement(net.minecraft.advancements.Advancement) MinecraftServer(net.minecraft.server.MinecraftServer)

Aggregations

Advancement (net.minecraft.advancements.Advancement)12 AdvancementProgress (net.minecraft.advancements.AdvancementProgress)4 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)4 ResourceLocation (net.minecraft.util.ResourceLocation)3 Map (java.util.Map)2 AdvancementCriterion (org.spongepowered.api.advancement.criteria.AdvancementCriterion)2 IMixinCriterion (org.spongepowered.common.interfaces.advancement.IMixinCriterion)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 TypeToken (com.google.common.reflect.TypeToken)1 BlockModFluid (com.teamwizardry.librarianlib.features.base.fluid.BlockModFluid)1 ModFluid (com.teamwizardry.librarianlib.features.base.fluid.ModFluid)1 EntityUpdateEvent (com.teamwizardry.librarianlib.features.forgeevents.EntityUpdateEvent)1 Wizardry (com.teamwizardry.wizardry.Wizardry)1 FluidTracker (com.teamwizardry.wizardry.api.block.FluidTracker)1 IExplodable (com.teamwizardry.wizardry.api.item.IExplodable)1 RandUtil (com.teamwizardry.wizardry.api.util.RandUtil)1 LibParticles (com.teamwizardry.wizardry.client.fx.LibParticles)1 DamageSourceMana (com.teamwizardry.wizardry.common.core.DamageSourceMana)1 FluidRecipeLoader (com.teamwizardry.wizardry.crafting.mana.FluidRecipeLoader)1