Added some more achievements

This commit is contained in:
Ellpeck 2016-08-05 04:49:04 +02:00
parent 85e622cd8e
commit 65aa7276ae
8 changed files with 139 additions and 28 deletions

View file

@ -12,7 +12,12 @@ package de.ellpeck.actuallyadditions.mod.achievement;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.stats.Achievement;
import net.minecraft.stats.AchievementList;
import net.minecraft.stats.StatisticsManager;
import net.minecraft.util.JsonSerializableSet;
import net.minecraftforge.common.AchievementPage;
import java.util.ArrayList;

View file

@ -13,37 +13,61 @@ package de.ellpeck.actuallyadditions.mod.achievement;
import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements.Type;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.init.Items;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.stats.AchievementList;
import net.minecraft.stats.StatisticsManager;
import net.minecraft.util.JsonSerializableSet;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public enum TheAchievements{
OPEN_BOOKLET("openBooklet", 0, 0, new ItemStack(InitItems.itemBooklet), null, Type.MISC),
NAME_SMILEY_CLOUD("nameSmileyCloud", 4, 2, new ItemStack(InitBlocks.blockSmileyCloud), null, Type.MISC, true),
NAME_SMILEY_CLOUD("nameSmileyCloud", 4, 3, new ItemStack(InitBlocks.blockSmileyCloud), null, Type.MISC, true, 0),
OPEN_TREASURE_CHEST("openTreasureChest", 1, -3, new ItemStack(InitBlocks.blockTreasureChest), OPEN_BOOKLET, Type.MISC),
CRAFT_COAL_GEN("craftCoalGen", -2, 0, new ItemStack(InitBlocks.blockCoalGenerator), OPEN_BOOKLET),
CRAFT_LEAF_GEN("craftLeafGen", -3, -2, new ItemStack(InitBlocks.blockLeafGenerator), CRAFT_COAL_GEN),
CRAFT_RECONSTRUCTOR("craftReconstructor", -5, 0, new ItemStack(InitBlocks.blockAtomicReconstructor), CRAFT_COAL_GEN),
MAKE_FIRST_CRYSTAL("makeCrystal", -4, 2, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), CRAFT_RECONSTRUCTOR, Type.PICK_UP, new ItemStack(InitItems.itemCrystal, 1, Util.WILDCARD), new ItemStack(InitBlocks.blockCrystal, 1, Util.WILDCARD)),
CRAFT_EMPOWERER("craftEmpowerer", -4, 4, new ItemStack(InitBlocks.blockEmpowerer), MAKE_FIRST_CRYSTAL),
CRAFT_PHANTOMFACE("craftPhantomface", 2, 0, new ItemStack(InitBlocks.blockPhantomface), OPEN_BOOKLET),
CRAFT_LIQUIFACE("craftLiquiface", 2, 2, new ItemStack(InitBlocks.blockPhantomLiquiface), CRAFT_PHANTOMFACE),
CRAFT_ENERGYFACE("craftEnergyface", 2, -2, new ItemStack(InitBlocks.blockPhantomEnergyface), CRAFT_PHANTOMFACE),
CRAFT_ENERGYFACE("craftEnergyface", 4, -1, new ItemStack(InitBlocks.blockPhantomEnergyface), CRAFT_PHANTOMFACE),
CRAFT_LASER_RELAY("craftLaserRelay", -7, -2, new ItemStack(InitBlocks.blockLaserRelay), CRAFT_RECONSTRUCTOR),
CRAFT_LASER_RELAY_ITEM("craftLaserRelayItem", -9, -2, new ItemStack(InitBlocks.blockLaserRelayItem), CRAFT_LASER_RELAY),
CRAFT_ITEM_INTERFACE("craftItemInterface", -11, -3, new ItemStack(InitBlocks.blockItemViewer), CRAFT_LASER_RELAY_ITEM),
CRAFT_LASER_RELAY_ADVANCED("craftLaserRelayAdvanced", -7, -4, new ItemStack(InitBlocks.blockLaserRelayAdvanced), CRAFT_LASER_RELAY),
CRAFT_LASER_RELAY_EXTREME("craftLaserRelayExtreme", -9, -4, new ItemStack(InitBlocks.blockLaserRelayExtreme), CRAFT_LASER_RELAY_ADVANCED),
CRAFT_CRUSHER("craftCrusher", -8, 0, new ItemStack(InitBlocks.blockGrinder), CRAFT_RECONSTRUCTOR),
PICK_UP_COFFEE("pickUpCoffee", -4, 2, new ItemStack(InitItems.itemCoffeeBean), CRAFT_RECONSTRUCTOR, Type.PICK_UP),
CRAFT_COFFEE_MACHINE("craftCoffeeMachine", -3, 3, new ItemStack(InitBlocks.blockCoffeeMachine), PICK_UP_COFFEE),
OBSCURED("obscured", 5, -5, new ItemStack(Items.RECORD_11), null, Type.MISC, true),
CRAFT_FIREWORK_BOX("craftFireworkBox", -6, -4, new ItemStack(InitBlocks.blockFireworkBox), null, Type.CRAFTING, true);
CRAFT_DOUBLE_CRUSHER("craftDoubleCrusher", -10, 1, new ItemStack(InitBlocks.blockGrinderDouble), CRAFT_CRUSHER),
PICK_UP_COFFEE("pickUpCoffee", -2, 2, new ItemStack(InitItems.itemCoffeeBean), CRAFT_COAL_GEN, Type.PICK_UP),
CRAFT_COFFEE_MACHINE("craftCoffeeMachine", -1, 3, new ItemStack(InitBlocks.blockCoffeeMachine), PICK_UP_COFFEE),
CRAFT_FIREWORK_BOX("craftFireworkBox", -4, -5, new ItemStack(InitBlocks.blockFireworkBox), null, Type.CRAFTING, true, 0),
GET_CRYSTALS_MILESTONE("getCrystalsMilestone", 6, -3, new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.DIAMOND.ordinal()), null, Type.PICK_UP, true, 200, new ItemStack(InitItems.itemCrystal, 1, Util.WILDCARD), new ItemStack(InitBlocks.blockCrystal, 1, Util.WILDCARD)),
OPEN_BOOKLET_MILESTONE("openBookletMilestone", 6, -1, new ItemStack(InitItems.itemBooklet), null, Type.MISC, true, 50);
public final Achievement chieve;
public final Type type;
public final int progressToReach;
public List<ItemStack> itemsToBeGotten;
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore){
this(name, x, y, displayStack, hasToHaveBefore, Type.CRAFTING, false);
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, ItemStack... specialItemsToBeGotten){
this(name, x, y, displayStack, hasToHaveBefore, Type.CRAFTING, false, 0, specialItemsToBeGotten);
}
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, Type type, boolean special){
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, Type type, boolean special, int progressToReach, ItemStack... specialItemsToBeGotten){
this.type = type;
this.progressToReach = progressToReach;
this.chieve = new Achievement("achievement."+ModUtil.MOD_ID+"."+name, ModUtil.MOD_ID+"."+name, x, y, displayStack, hasToHaveBefore == null ? null : hasToHaveBefore.chieve);
if(hasToHaveBefore == null){
this.chieve.initIndependentStat();
@ -51,11 +75,67 @@ public enum TheAchievements{
if(special){
this.chieve.setSpecial();
}
if(progressToReach > 0){
this.chieve.setSerializableClazz(JsonSerializableSet.class);
}
this.chieve.registerStat();
this.type = type;
if(specialItemsToBeGotten == null || specialItemsToBeGotten.length <= 0){
this.itemsToBeGotten = Collections.singletonList(displayStack);
}
else{
this.itemsToBeGotten = Arrays.asList(specialItemsToBeGotten);
}
}
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, Type type){
this(name, x, y, displayStack, hasToHaveBefore, type, false);
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, Type type, ItemStack... specialItemsToBeGotten){
this(name, x, y, displayStack, hasToHaveBefore, type, false, 0, specialItemsToBeGotten);
}
public void get(EntityPlayer player){
this.get(player, 1);
}
public void get(EntityPlayer player, int amount){
if(this.progressToReach > 0){
this.updateStatus(player, amount);
}
else{
player.addStat(this.chieve);
}
}
private void updateStatus(EntityPlayer player, int amount){
if(this.progressToReach > 0 && player instanceof EntityPlayerMP){
StatisticsManager manager = ((EntityPlayerMP)player).getStatFile();
if(manager != null && !manager.hasAchievementUnlocked(this.chieve) && manager.canUnlockAchievement(this.chieve)){
JsonSerializableSet data = manager.getProgress(this.chieve);
if(data == null){
data = manager.setProgress(this.chieve, new JsonSerializableSet());
}
int gottenSoFar = 0;
for(String strg : data){
try{
int i = Integer.parseInt(strg);
gottenSoFar += i;
data.remove(strg);
}
catch(Exception e){
data.remove(strg);
}
}
gottenSoFar += amount;
if(gottenSoFar >= this.progressToReach){
player.addStat(this.chieve);
}
else{
data.add(Integer.toString(gottenSoFar));
}
}
}
}
}

View file

@ -84,7 +84,6 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
else if(item == Items.RECORD_11){
reconstructor.counter++;
reconstructor.markDirty();
player.addStat(TheAchievements.OBSCURED.chieve);
}
}
else{

View file

@ -79,7 +79,7 @@ public class BlockSmileyCloud extends BlockContainerBase{
if(tile instanceof TileEntitySmileyCloud){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.CLOUD.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
player.addStat(TheAchievements.NAME_SMILEY_CLOUD.chieve);
TheAchievements.NAME_SMILEY_CLOUD.get(player);
}
}
return true;

View file

@ -72,7 +72,7 @@ public class BlockTreasureChest extends BlockBase{
this.dropItems(world, pos);
world.setBlockToAir(pos);
player.addStat(TheAchievements.OPEN_TREASURE_CHEST.chieve);
TheAchievements.OPEN_TREASURE_CHEST.get(player);
}
return true;
}

View file

@ -18,6 +18,7 @@ import de.ellpeck.actuallyadditions.mod.data.WorldData;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.entity.item.EntityItem;
@ -44,11 +45,11 @@ public class CommonEvents{
}
public static void checkAchievements(ItemStack gotten, EntityPlayer player, InitAchievements.Type type){
for(TheAchievements ach : TheAchievements.values()){
if(ach.type == type){
if(gotten != null && ach.chieve.theItemStack != null && gotten.getItem() == ach.chieve.theItemStack.getItem()){
if(gotten.getItemDamage() == ach.chieve.theItemStack.getItemDamage()){
player.addStat(ach.chieve, 1);
if(gotten != null){
for(TheAchievements ach : TheAchievements.values()){
if(ach.type == type){
if(ItemUtil.contains(ach.itemsToBeGotten, gotten, true)){
ach.get(player);
}
}
}

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements;
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
import de.ellpeck.actuallyadditions.mod.booklet.BookletUtils;
@ -79,7 +80,8 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.BOOK.ordinal(), world, (int)player.posX, (int)player.posY, (int)player.posZ);
if(!world.isRemote){
player.addStat(TheAchievements.OPEN_BOOKLET.chieve);
TheAchievements.OPEN_BOOKLET.get(player);
TheAchievements.OPEN_BOOKLET_MILESTONE.get(player);
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}

View file

@ -664,33 +664,57 @@ achievement.actuallyadditions.craftLiquiface.desc=Craft a Phantom Liquiface
achievement.actuallyadditions.craftEnergyface=Zoom, Zoom, RF!
achievement.actuallyadditions.craftEnergyface.desc=Craft a Phantom Energyface
achievement.actuallyadditions.craftCoalGen=Furnace for cools
achievement.actuallyadditions.craftCoalGen=Cool Generator
achievement.actuallyadditions.craftCoalGen.desc=Craft a Coal Generator
achievement.actuallyadditions.craftLeafGen=Munch, dude!
achievement.actuallyadditions.craftLeafGen=Munchdew?
achievement.actuallyadditions.craftLeafGen.desc=Craft a Leaf-Eating Generator
achievement.actuallyadditions.craftReconstructor=Bzrrrrt something else
achievement.actuallyadditions.craftReconstructor=Bzzzzrrrrt
achievement.actuallyadditions.craftReconstructor.desc=Craft an Atomic Reconstructor
achievement.actuallyadditions.craftEmpowerer=Infusion Altar
achievement.actuallyadditions.craftEmpowerer.desc=Craft an Empowerer
achievement.actuallyadditions.makeCrystal=Crystal clear
achievement.actuallyadditions.makeCrystal.desc=Make a Crystal with the Atomic Reconstructor
achievement.actuallyadditions.craftLaserRelay=Relayed, not delayed
achievement.actuallyadditions.craftLaserRelay.desc=Craft a Laser Relay
achievement.actuallyadditions.craftLaserRelayItem=Conducting information
achievement.actuallyadditions.craftLaserRelayItem.desc=Craft an Item Laser Relay
achievement.actuallyadditions.craftItemInterface=Show your face
achievement.actuallyadditions.craftItemInterface.desc=Craft an Item Interface
achievement.actuallyadditions.craftLaserRelayAdvanced=Energetic expansion
achievement.actuallyadditions.craftLaserRelayAdvanced.desc=Craft an Advanced Laser Relay
achievement.actuallyadditions.craftLaserRelayExtreme=Mad with power
achievement.actuallyadditions.craftLaserRelayExtreme.desc=Craft an Extreme Laser Relay
achievement.actuallyadditions.craftCrusher=Doublin' up!
achievement.actuallyadditions.craftCrusher.desc=Craft a Crusher
achievement.actuallyadditions.craftDoubleCrusher=Double doublin' up!
achievement.actuallyadditions.craftCrusher.desc=Craft a Double Crusher
achievement.actuallyadditions.pickUpCoffee=Makes you addicted
achievement.actuallyadditions.pickUpCoffee.desc=Harvest some coffee
achievement.actuallyadditions.craftCoffeeMachine=Addiction in cups
achievement.actuallyadditions.craftCoffeeMachine.desc=Craft a Coffee Maker
achievement.actuallyadditions.obscured=§ksome chieve name
achievement.actuallyadditions.obscured.desc=§klolwut y u actually look over meow
achievement.actuallyadditions.craftFireworkBox=Bang Boom Bang
achievement.actuallyadditions.craftFireworkBox.desc=Craft a Firework Box
achievement.actuallyadditions.getCrystalsMilestone=Reconstruction Master
achievement.actuallyadditions.getCrystalsMilestone.desc=Create 200 Crystals
achievement.actuallyadditions.openBookletMilestone=Bookworm!
achievement.actuallyadditions.openBookletMilestone.desc=Open the Manual 50 times
#Booklet Recipe Names
booklet.actuallyadditions.shapelessRecipe=Shapeless Recipe
booklet.actuallyadditions.shapedRecipe=Shaped Recipe