Replace Achievements with Advancements
- Advancements are now in JSON files, converted by the included migration script. - WizardryAdvancementTrigger is a generic achievement trigger that can be reused throughout the code to trigger custom advancements not covered by the JSON conditions. - Plus some other small and obvious fixes.
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
package electroblob.wizardry.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import electroblob.wizardry.WizardData;
|
||||
import electroblob.wizardry.advancement.AdvancementHelper;
|
||||
import electroblob.wizardry.advancement.AdvancementHelper.EnumAdvancement;
|
||||
import electroblob.wizardry.event.DiscoverSpellEvent;
|
||||
import electroblob.wizardry.registry.WizardryAdvancementTriggers;
|
||||
import electroblob.wizardry.registry.WizardryTabs;
|
||||
import electroblob.wizardry.spell.Spell;
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
@@ -24,6 +23,9 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemIdentificationScroll extends Item {
|
||||
|
||||
public ItemIdentificationScroll(){
|
||||
@@ -65,7 +67,7 @@ public class ItemIdentificationScroll extends Item {
|
||||
// Identification scrolls give the chat readout in creative mode, otherwise it looks like
|
||||
// nothing happens!
|
||||
properties.discoverSpell(spell);
|
||||
AdvancementHelper.grantAdvancement(player, EnumAdvancement.identify_spell);
|
||||
WizardryAdvancementTriggers.identify_spell.triggerFor(player);
|
||||
player.playSound(SoundEvents.ENTITY_PLAYER_LEVELUP, 1.25f, 1);
|
||||
if(!player.capabilities.isCreativeMode) stack.shrink(1);
|
||||
if(!world.isRemote) player.sendMessage(new TextComponentTranslation("spell.discover",
|
||||
@@ -83,5 +85,5 @@ public class ItemIdentificationScroll extends Item {
|
||||
|
||||
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ItemSpellBook extends Item {
|
||||
|
||||
public ItemSpellBook(){
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package electroblob.wizardry.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import electroblob.wizardry.SpellGlyphData;
|
||||
import electroblob.wizardry.WizardData;
|
||||
import electroblob.wizardry.Wizardry;
|
||||
@@ -15,6 +13,7 @@ import electroblob.wizardry.event.SpellCastEvent;
|
||||
import electroblob.wizardry.event.SpellCastEvent.Source;
|
||||
import electroblob.wizardry.packet.PacketCastSpell;
|
||||
import electroblob.wizardry.packet.WizardryPacketHandler;
|
||||
import electroblob.wizardry.registry.WizardryAdvancementTriggers;
|
||||
import electroblob.wizardry.registry.WizardryItems;
|
||||
import electroblob.wizardry.registry.WizardryPotions;
|
||||
import electroblob.wizardry.registry.WizardryTabs;
|
||||
@@ -46,6 +45,9 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is (literally) where the magic happens! All wand types are single instances of this class. There's a lot
|
||||
* of quite hard-to-read code in here, but unfortunately there's not much I can do about that. For this reason, I have
|
||||
@@ -97,11 +99,6 @@ public class ItemWand extends Item {
|
||||
* WandHelper.getUpgradeLevel(itemstack, WizardryItems.storage_upgrade)) + 0.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack stack, World par2World, EntityPlayer player){
|
||||
AdvancementHelper.grantAdvancement(player, EnumAdvancement.arcane_initiate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack itemstack, World world, Entity entity, int slot, boolean isHeld){
|
||||
|
||||
@@ -118,10 +115,8 @@ public class ItemWand extends Item {
|
||||
if(entity instanceof EntityPlayer && this.element != null && this.element != Element.MAGIC){
|
||||
// As it stands, this will trigger every tick. Not ideal, but I can't find a way to detect if a player
|
||||
// has a certain achievement.
|
||||
// EDIT: There is a way to check, using StatFileWriter#hasAchievementUnlocked, but this ends up calling the
|
||||
// same
|
||||
// thing as addStat anyway, meaning there's no point and it's probably not much of a problem anyway.
|
||||
AdvancementHelper.grantAdvancement((EntityPlayer)entity, EnumAdvancement.elemental);
|
||||
// TODO: check if this is somehow triggerable via JSON conditions.
|
||||
WizardryAdvancementTriggers.element_master.triggerFor((EntityPlayer)entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package electroblob.wizardry.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import electroblob.wizardry.advancement.AdvancementHelper;
|
||||
import electroblob.wizardry.advancement.AdvancementHelper.EnumAdvancement;
|
||||
import electroblob.wizardry.constants.Constants;
|
||||
import electroblob.wizardry.constants.Element;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import electroblob.wizardry.registry.WizardryAdvancementTriggers;
|
||||
import electroblob.wizardry.registry.WizardryTabs;
|
||||
import electroblob.wizardry.spell.Petrify;
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -30,6 +29,9 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class ItemWizardArmour extends ItemArmor implements ISpecialArmor {
|
||||
|
||||
@@ -233,7 +235,7 @@ public class ItemWizardArmour extends ItemArmor implements ISpecialArmor {
|
||||
}
|
||||
}
|
||||
// If it gets this far, then all slots must be wizard armour, so trigger the achievement.
|
||||
AdvancementHelper.grantAdvancement(player, EnumAdvancement.armour_set);
|
||||
WizardryAdvancementTriggers.armour_set.triggerFor(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user