Fixed achievement saving and a crash due to positioning
This commit is contained in:
parent
7a4043a4aa
commit
ea575db71c
2 changed files with 59 additions and 55 deletions
|
@ -40,67 +40,71 @@ public class AchievementEventHandler
|
|||
@SubscribeEvent
|
||||
public void onItemPickup(PlayerEvent.ItemPickupEvent event)
|
||||
{
|
||||
//Only add achievements on the server
|
||||
if (event.player.worldObj.isRemote)
|
||||
return;
|
||||
|
||||
Item item = event.pickedUp.getEntityItem().getItem();
|
||||
Block block = Block.getBlockFromItem(item);
|
||||
EntityPlayer player = event.player;
|
||||
|
||||
if (block != null && block instanceof BlockBOPLog)
|
||||
{
|
||||
event.player.addStat(AchievementList.mineWood, 1);
|
||||
player.triggerAchievement(AchievementList.mineWood);
|
||||
}
|
||||
|
||||
//Flower Child Achievement
|
||||
if (block != null && block instanceof BlockBOPFlower)
|
||||
{
|
||||
player.addStat(BOPAchievements.obtain_flowers, 1);
|
||||
player.triggerAchievement(BOPAchievements.obtain_flowers);
|
||||
}
|
||||
|
||||
//Berry Good Achievement
|
||||
if (item != null && item == BOPItems.berries)
|
||||
{
|
||||
player.addStat(BOPAchievements.obtain_berry, 1);
|
||||
player.triggerAchievement(BOPAchievements.obtain_berry);
|
||||
}
|
||||
|
||||
//Totally Coral Achievement
|
||||
if (block != null && block == BOPBlocks.coral)
|
||||
{
|
||||
player.addStat(BOPAchievements.obtain_coral, 1);
|
||||
player.triggerAchievement(BOPAchievements.obtain_coral);
|
||||
}
|
||||
|
||||
//Rather Thorny Achievement
|
||||
if (block != null && block == BlockBOPPlant.paging.getBlock(BOPPlants.THORN))
|
||||
{
|
||||
player.addStat(BOPAchievements.obtain_thorn, 1);
|
||||
player.triggerAchievement(BOPAchievements.obtain_thorn);
|
||||
}
|
||||
|
||||
//Pick Your Poison Achievement
|
||||
if (block != null && block == BlockBOPPlant.paging.getBlock(BOPPlants.POISONIVY))
|
||||
{
|
||||
player.addStat(BOPAchievements.obtain_poison_ivy, 1);
|
||||
player.triggerAchievement(BOPAchievements.obtain_poison_ivy);
|
||||
}
|
||||
|
||||
//Stalk Market Achievement
|
||||
if (item != null && item == BOPItems.turnip)
|
||||
{
|
||||
player.addStat(BOPAchievements.obtain_turnip, 1);
|
||||
player.triggerAchievement(BOPAchievements.obtain_turnip);
|
||||
}
|
||||
|
||||
//Honeycomb Crunch Achievement
|
||||
if (item != null && item == BOPItems.honeycomb)
|
||||
{
|
||||
player.addStat(BOPAchievements.obtain_honeycomb, 1);
|
||||
player.triggerAchievement(BOPAchievements.obtain_honeycomb);
|
||||
}
|
||||
|
||||
//Don't Breathe This Achievement
|
||||
if (item != null && item == BOPItems.pixie_dust)
|
||||
{
|
||||
player.addStat(BOPAchievements.obtain_pixie_dust, 1);
|
||||
player.triggerAchievement(BOPAchievements.obtain_pixie_dust);
|
||||
}
|
||||
|
||||
//Far Out Achievement
|
||||
if (item != null && item == BOPItems.crystal_shard)
|
||||
{
|
||||
player.addStat(BOPAchievements.obtain_celestial_crystal, 1);
|
||||
player.triggerAchievement(BOPAchievements.obtain_celestial_crystal);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import net.minecraft.stats.Achievement;
|
|||
import net.minecraftforge.common.AchievementPage;
|
||||
import biomesoplenty.api.block.BOPBlocks;
|
||||
import biomesoplenty.api.item.BOPItems;
|
||||
import biomesoplenty.common.block.BlockBOPGrass;
|
||||
import biomesoplenty.common.block.BlockBOPPlant;
|
||||
import biomesoplenty.common.enums.BOPPlants;
|
||||
|
||||
|
@ -50,13 +49,14 @@ public class ModAchievements
|
|||
obtain_honeycomb = addAchievement("achievement.obtain_honeycomb", "obtain_honeycomb", 3, -3, new ItemStack(BOPItems.honeycomb), obtain_coral);
|
||||
obtain_pixie_dust = addAchievement("achievement.obtain_pixie_dust", "obtain_pixie_dust", 5, -4, new ItemStack(BOPItems.pixie_dust), obtain_honeycomb);
|
||||
obtain_celestial_crystal = addAchievement("achievement.obtain_celestial_crystal", "obtain_celestial_crystal", 7, -1, new ItemStack(BOPItems.crystal_shard), obtain_pixie_dust);
|
||||
craft_ornamental_artifact = addAchievement("achievement.craft_ornamental_artifact", "craft_ornamental_artifact", 3, -8, new ItemStack(BOPItems.gem), obtain_pixie_dust);
|
||||
explore_all_biomes = addAchievement("achievement.explore_all_biomes", "explore_all_biomes", 0, -8, new ItemStack(BOPItems.earth), craft_ornamental_artifact).setSpecial();
|
||||
craft_ornamental_artifact = addAchievement("achievement.craft_ornamental_artifact", "craft_ornamental_artifact", 3, -6, new ItemStack(BOPItems.gem), obtain_pixie_dust);
|
||||
explore_all_biomes = addAchievement("achievement.explore_all_biomes", "explore_all_biomes", 0, -7, new ItemStack(BOPItems.earth), craft_ornamental_artifact).setSpecial();
|
||||
}
|
||||
|
||||
private static Achievement addAchievement(String unlocalizedName, String identifier, int column, int row, ItemStack iconStack, Achievement parent)
|
||||
{
|
||||
Achievement achievement = new Achievement(unlocalizedName, identifier, column, row, iconStack, parent);
|
||||
achievement.registerStat();
|
||||
achievementPage.getAchievements().add(achievement);
|
||||
return achievement;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue