BiomesOPlenty/src/minecraft/biomesoplenty/helpers/AchievementHelper.java

177 lines
9.3 KiB
Java
Raw Normal View History

2013-05-03 13:00:44 +00:00
package biomesoplenty.helpers;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.stats.AchievementList;
2013-05-03 13:00:44 +00:00
import net.minecraftforge.common.AchievementPage;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import biomesoplenty.api.Blocks;
import biomesoplenty.api.Items;
import biomesoplenty.configuration.BOPConfiguration;
import cpw.mods.fml.common.registry.LanguageRegistry;
public class AchievementHelper
{
2013-05-31 10:34:02 +00:00
// Achievement declaration
public static Achievement achFlower;
public static Achievement achRedRock;
public static Achievement achThorn;
public static Achievement achAsh;
public static Achievement achOrigin;
public static Achievement achPromised;
public static Achievement achMud;
public static Achievement achShroom;
public static Achievement achBarley;
public static Achievement achMoss;
2013-06-15 11:08:58 +00:00
public static Achievement achFlowerP;
public static Achievement achBOP;
2013-06-25 23:11:07 +00:00
public static Achievement achAllBiomes;
public static Achievement achAlps;
public static Achievement achArctic;
2013-06-25 23:11:07 +00:00
public static Achievement achBadlands;
public static Achievement achBambooForest;
public static Achievement achBayou;
public static Achievement achBirchForest;
public static Achievement achBog;
public static Achievement achBorealForest;
public static Achievement achBrushland;
public static Achievement achCanyon;
public static Achievement achChaparral;
public static Achievement achCherryBlossom;
2013-05-31 10:34:02 +00:00
public static AchievementPage pageBOP;
public static AchievementPage pageBiome;
2013-05-03 13:00:44 +00:00
@ForgeSubscribe
public void EntityItemPickupEvent(EntityItemPickupEvent event)
{
onItemPickup(event.entityPlayer, event.item.getEntityItem());
}
2013-05-31 10:34:02 +00:00
2013-05-03 13:00:44 +00:00
public static void init()
{
2013-05-31 10:34:02 +00:00
achFlower = (new Achievement(3057, "achFlower", 0, 0, Block.plantRed, null)).registerAchievement();
achRedRock = (new Achievement(3058, "achRedRock", -2, 2, new ItemStack(Blocks.redRock.get(),1,0), achFlower)).registerAchievement();
achThorn = (new Achievement(3059, "achThorn", 2, 1, new ItemStack(Blocks.plants.get(),1,5), achFlower)).registerAchievement();
achAsh = (new Achievement(3060, "achAsh", 1, 3, new ItemStack(Items.miscItems.get(), 1, 1), achFlower)).registerAchievement();
achOrigin = (new Achievement(3061, "achOrigin", 0, 5, Blocks.originGrass.get(), achFlower)).setSpecial().registerAchievement();
achPromised = (new Achievement(3062, "achPromised", 0, -5, Blocks.holyGrass.get(), achFlower)).setSpecial().registerAchievement();
achMud = (new Achievement(3063, "achMud", -2, -1, Items.mudball.get(), achFlower)).registerAchievement();
achShroom = (new Achievement(3064, "achShroom", 2, -2, new ItemStack(Blocks.mushrooms.get(),1,0), achFlower)).registerAchievement();
achBarley = (new Achievement(3065, "achBarley", -1, 4, new ItemStack(Blocks.plants.get(),1,6), achFlower)).registerAchievement();
achMoss = (new Achievement(3066, "achMoss", -1, -3, Blocks.moss.get(), achFlower)).registerAchievement();
achFlowerP = (new Achievement(3067, "achFlowerP", 1, -4, new ItemStack(Items.flowerBand.get(), 1, 0), achFlower)).registerAchievement();
2013-06-25 23:11:07 +00:00
achBOP = (new Achievement(3080, "achBOP", -10, -6, new ItemStack(Blocks.saplings.get(), 1, 6), null)).registerAchievement().setSpecial();
achAllBiomes = (new Achievement(3081, "achAllBiomes", 12, 6, new ItemStack(Blocks.saplings.get(), 1, 6), null)).registerAchievement().setSpecial();
achAlps = (new Achievement(3082, "achAlps", -8, -6, new ItemStack(Block.stone, 1, 0), achBOP)).registerAchievement();
achArctic = (new Achievement(3083, "achArctic", -6, -6, new ItemStack(Block.blockSnow, 1, 0), achBOP)).registerAchievement();
achBadlands = (new Achievement(3084, "achBadlands", -4, -6, new ItemStack(Blocks.hardSand.get(), 1, 0), achBOP)).registerAchievement();
achBambooForest = (new Achievement(3085, "achBambooForest", -2, -6, new ItemStack(Blocks.saplings.get(), 1, 2), achBOP)).registerAchievement();
achBayou = (new Achievement(3086, "achBayou", 0, -6, new ItemStack(Blocks.logs3.get(), 1, 1), achBOP)).registerAchievement();
achBirchForest = (new Achievement(3087, "achBirchForest", 2, -6, new ItemStack(Block.sapling, 1, 2), achBOP)).registerAchievement();
achBog = (new Achievement(3088, "achBog", 4, -6, new ItemStack(Blocks.plants.get(), 1, 8), achBOP)).registerAchievement();
achBorealForest = (new Achievement(3089, "achBorealForest", 6, -6, new ItemStack(Blocks.saplings.get(), 1, 1), achBOP)).registerAchievement();
achBrushland = (new Achievement(3090, "achBrushland", 8, -6, new ItemStack(Block.leaves, 1, 2), achBOP)).registerAchievement();
achCanyon = (new Achievement(3091, "achCanyon", 10, -6, new ItemStack(Blocks.hardDirt.get(), 1, 0), achBOP)).registerAchievement();
achChaparral = (new Achievement(3092, "achChaparral", -10, -4, new ItemStack(Blocks.foliage.get(), 1, 4), achBOP)).registerAchievement();
achCherryBlossom = (new Achievement(3093, "achCherryBlossom", -8, -4, new ItemStack(Blocks.saplings.get(), 1, 10), achBOP)).registerAchievement();
2013-05-31 10:34:02 +00:00
pageBOP = new AchievementPage("Biomes O\' Plenty", new Achievement[] {achFlower, achRedRock, achThorn, achAsh, achOrigin, achPromised, achMud, achShroom, achBarley, achMoss, achFlowerP});
2013-06-25 23:11:07 +00:00
pageBiome = new AchievementPage("Biome Finder", new Achievement[] {achBOP, achAllBiomes, achAlps, achArctic, achBadlands, achBambooForest, achBayou, achBirchForest, achBog, achBorealForest, achBrushland, achCanyon, achChaparral, achCherryBlossom});
2013-05-31 10:34:02 +00:00
AchievementPage.registerAchievementPage(pageBOP);
AchievementPage.registerAchievementPage(pageBiome);
2013-05-03 13:00:44 +00:00
2013-05-31 10:34:02 +00:00
// Add Achievement registration
addAchievementDesc("achFlower", "Flower Child", "Pick some flowers!");
addAchievementDesc("achRedRock", "Red Rocky Mountain High", "Dig out some red rocks.");
addAchievementDesc("achThorn", "Rather Thorny...", "Don\'t get cut!");
addAchievementDesc("achAsh", "Ashes, Ashes...", "Man, this song is creepy.");
addAchievementDesc("achOrigin", "Alpha...", "Where it all began.");
addAchievementDesc("achPromised", "...Omega", "Welcome to the Promised Land!");
addAchievementDesc("achMud", "Sticky Situation", "I just had these boots cleaned!");
addAchievementDesc("achShroom", "Trippin\'", "Don\'t try this at home, kids!");
addAchievementDesc("achBarley", "Fields Of Gold", "Upon the fields of barley.");
addAchievementDesc("achMoss", "A Rolling Stone Gathers No Moss", "Wait, cubes can't roll...");
addAchievementDesc("achFlowerP", "Flower Power!", "Groovy, man.");
2013-06-25 23:11:07 +00:00
addAchievementDesc("achBOP", "Biomes O\' Plenty", "Let the fun begin!");
addAchievementDesc("achAllBiomes", "All Biomes Found!", "You've been to every biome!");
addAchievementDesc("achAlps", "Alps", "Biome Found!");
addAchievementDesc("achArctic", "Arctic", "Biome Found!");
2013-06-25 23:11:07 +00:00
addAchievementDesc("achBadlands", "Badlands", "Biome Found!");
addAchievementDesc("achBambooForest", "Bamboo Forest", "Biome Found!");
addAchievementDesc("achBayou", "Bayou", "Biome Found!");
addAchievementDesc("achBirchForest", "Birch Forest", "Biome Found!");
addAchievementDesc("achBog", "Bog", "Biome Found!");
addAchievementDesc("achBorealForest", "Boreal Forest", "Biome Found!");
addAchievementDesc("achBrushland", "Brushland", "Biome Found!");
addAchievementDesc("achCanyon", "Canyon", "Biome Found!");
addAchievementDesc("achChaparral", "Chaparral", "Biome Found!");
addAchievementDesc("achCherryBlossom", "Cherry Blossom Grove", "Biome Found!");
2013-05-03 13:00:44 +00:00
}
2013-05-31 10:34:02 +00:00
2013-05-03 13:00:44 +00:00
// Achievement checker
2013-05-31 10:34:02 +00:00
private static void onItemPickup(EntityPlayer player, ItemStack item)
{
if (BOPConfiguration.achievements == true)
{
if (item.itemID == Blocks.flowers.get().blockID || item.itemID == Block.plantRed.blockID || item.itemID == Block.plantYellow.blockID)
{
player.addStat(achFlower, 1);
}
if (item.itemID == Blocks.redRock.get().blockID)
{
player.addStat(achRedRock, 1);
}
if (item.itemID == Blocks.plants.get().blockID && item.getItemDamage() == 5)
{
player.addStat(achThorn, 1);
}
if (item.itemID == Items.miscItems.get().itemID && item.getItemDamage() == 1)
{
player.addStat(achAsh, 1);
}
if (item.itemID == Blocks.originGrass.get().blockID)
{
player.addStat(achOrigin, 1);
}
if (item.itemID == Blocks.holyGrass.get().blockID || item.itemID == Blocks.holyStone.get().blockID)
{
player.addStat(achPromised, 1);
}
if (item.itemID == Items.mudball.get().itemID)
{
player.addStat(achMud, 1);
}
if (item.itemID == Blocks.mushrooms.get().blockID && item.getItemDamage() == 0)
{
player.addStat(achShroom, 1);
}
if (item.itemID == Blocks.planks.get().blockID && item.getItemDamage() == 6)
{
player.addStat(achBarley, 1);
}
if (item.itemID == Blocks.moss.get().blockID)
{
player.addStat(achMoss, 1);
}
}
if (item.itemID == Blocks.logs1.get().blockID || item.itemID == Blocks.logs2.get().blockID || (item.itemID == Blocks.logs3.get().blockID && item.getItemDamage() < 3) || item.itemID == Blocks.logs4.get().blockID) {
player.addStat(AchievementList.mineWood, 1);
}
}
private static void addAchievementDesc(String ach, String name, String desc)
{
LanguageRegistry.instance().addStringLocalization("achievement." + ach, "en_US", name);
LanguageRegistry.instance().addStringLocalization("achievement." + ach + ".desc", "en_US", desc);
}
2013-05-03 13:00:44 +00:00
}