Achievement based unlocking done.
This commit is contained in:
parent
a650dc425c
commit
0cedc2195a
2 changed files with 40 additions and 15 deletions
|
@ -26,6 +26,7 @@ import gregtech.api.util.GT_Utility;
|
|||
import gregtech.common.entities.GT_Entity_Arrow;
|
||||
import gregtech.common.entities.GT_Entity_Arrow_Potion;
|
||||
import gregtech.common.render.*;
|
||||
import gregtech.loaders.misc.GT_Achievements;
|
||||
import gregtech.nei.NEI_GT_Config;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -33,6 +34,8 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.stats.StatFileWriter;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -77,7 +80,7 @@ public class GT_Client extends GT_Proxy
|
|||
private final List mMoltenNegA = Arrays.asList(new Object[0]);
|
||||
private long mAnimationTick;
|
||||
/**This is the place to def the value used below**/
|
||||
//private long afterSomeTime;
|
||||
private long afterSomeTime;
|
||||
private boolean mAnimationDirection;
|
||||
private boolean isFirstClientPlayerTick;
|
||||
private String mMessage;
|
||||
|
@ -287,6 +290,18 @@ public class GT_Client extends GT_Proxy
|
|||
@SubscribeEvent
|
||||
public void onPlayerTickEventClient(TickEvent.PlayerTickEvent aEvent) {
|
||||
if ((aEvent.side.isClient()) && (aEvent.phase == TickEvent.Phase.END) && (!aEvent.player.isDead)) {
|
||||
/**Something on the lines of this works for recipe visibility toggling**/
|
||||
/**yes just change the mHidden thing, rest is done by custom NEI configurer GT_NEI_AssLineHandler**/
|
||||
afterSomeTime++;
|
||||
if(afterSomeTime>=100L){
|
||||
afterSomeTime=0;
|
||||
StatFileWriter sfw= Minecraft.getMinecraft().thePlayer.getStatFileWriter();
|
||||
try {
|
||||
for(GT_Recipe recipe:GT_Recipe.GT_Recipe_Map.sAssemblylineFakeRecipes.mRecipeList){
|
||||
recipe.mHidden=!sfw.hasAchievementUnlocked(GT_Mod.achievements.getAchievement(recipe.getOutput(0).getUnlocalizedName()));
|
||||
}
|
||||
}catch (Exception e){}
|
||||
}
|
||||
ArrayList<GT_PlayedSound> tList = new ArrayList();
|
||||
for (Map.Entry<GT_PlayedSound, Integer> tEntry : GT_Utility.sPlayedSoundMap.entrySet()) {
|
||||
if (tEntry.getValue().intValue() < 0) {//Integer -> Integer -> int? >_<, fix
|
||||
|
@ -362,17 +377,6 @@ public class GT_Client extends GT_Proxy
|
|||
public void onClientTickEvent(cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent aEvent) {
|
||||
if (aEvent.phase == cpw.mods.fml.common.gameevent.TickEvent.Phase.END) {
|
||||
mAnimationTick++;
|
||||
/**Something on the lines of this works for recipe visibility toggling**/
|
||||
/**yes just change the mHidden thing, rest is done by custom NEI configurer GT_NEI_AssLineHandler**/
|
||||
//if(!isFirstClientPlayerTick)afterSomeTime++;
|
||||
//if(afterSomeTime>=600L){
|
||||
// afterSomeTime=0;
|
||||
// try {
|
||||
// for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineFakeRecipes.mRecipeList) {
|
||||
// recipe.mHidden ^= true;
|
||||
// }
|
||||
// }catch (Exception e){}
|
||||
//}
|
||||
if (mAnimationTick % 50L == 0L)
|
||||
{mAnimationDirection = !mAnimationDirection;}
|
||||
int tDirection = mAnimationDirection ? 1 : -1;
|
||||
|
|
|
@ -15,6 +15,7 @@ import gregtech.api.objects.ItemData;
|
|||
import gregtech.api.util.GT_Log;
|
||||
import gregtech.api.util.GT_ModHandler;
|
||||
import gregtech.api.util.GT_OreDictUnificator;
|
||||
import gregtech.api.util.GT_Recipe;
|
||||
import gregtech.common.items.GT_MetaGenerated_Tool_01;
|
||||
import ic2.core.Ic2Items;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -38,6 +39,7 @@ public class GT_Achievements {
|
|||
public static List<Materials> oreList = new ArrayList<Materials>();
|
||||
public static List<Integer[]> oreStats = new ArrayList<Integer[]>();
|
||||
public static int oreReg = -1;
|
||||
public static int assReg=-1;
|
||||
public ConcurrentHashMap<String, Achievement> achievementList;
|
||||
public ConcurrentHashMap<String, Boolean> issuedAchievements;
|
||||
public int adjX = 5;
|
||||
|
@ -71,6 +73,10 @@ public class GT_Achievements {
|
|||
}
|
||||
registerOreAchievement(oreList.get(i));
|
||||
}
|
||||
|
||||
for(GT_Recipe recipe: GT_Recipe.GT_Recipe_Map.sAssemblylineFakeRecipes.mRecipeList)
|
||||
registerAssAchievement(recipe);
|
||||
|
||||
registerAchievement("flintpick", 0, 0, GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(2, 1, Materials.Flint, Materials.Wood, null), "", false);
|
||||
registerAchievement("crops", -4, 0, GT_ModHandler.getIC2Item("crop", 1L), "flintpick", false);
|
||||
registerAchievement("havestlead", -4, 2, ItemList.Crop_Drop_Plumbilia.get(1, new Object[]{}), "crops", false);
|
||||
|
@ -215,7 +221,6 @@ public class GT_Achievements {
|
|||
if (!GT_Mod.gregtechproxy.mAchievements) {
|
||||
return null;
|
||||
}
|
||||
;
|
||||
Achievement achievement = new Achievement(textId, textId, this.adjX + x, this.adjY + y, icon, requirement);
|
||||
if (special) {
|
||||
achievement.setSpecial();
|
||||
|
@ -256,6 +261,15 @@ public class GT_Achievements {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Achievement registerAssAchievement(GT_Recipe recipe) {
|
||||
if (this.achievementList.get(recipe.getOutput(0).getUnlocalizedName()) == null) {
|
||||
assReg++;
|
||||
return registerAchievement(recipe.getOutput(0).getUnlocalizedName(), -(11 + assReg % 5), ((assReg) / 5) - 8, recipe.getOutput(0)
|
||||
, AchievementList.openInventory, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void issueAchievement(EntityPlayer entityplayer, String textId) {
|
||||
if (entityplayer == null || !GT_Mod.gregtechproxy.mAchievements) {
|
||||
return;
|
||||
|
@ -561,8 +575,15 @@ public class GT_Achievements {
|
|||
}
|
||||
} else if (stack.getUnlocalizedName().equals("gt.Thoriumcell")) {
|
||||
issueAchievement(player, "newfuel");
|
||||
}else if ((stack.getItem() == Ic2Items.quantumBodyarmor.getItem()) || (stack.getItem() == Ic2Items.quantumBoots.getItem()) ||
|
||||
} else if ((stack.getItem() == Ic2Items.quantumBodyarmor.getItem()) || (stack.getItem() == Ic2Items.quantumBoots.getItem()) ||
|
||||
(stack.getItem() == Ic2Items.quantumHelmet.getItem()) || (stack.getItem() == Ic2Items.quantumLeggings.getItem())) {
|
||||
issueAchievement(player, "buildQArmor");}
|
||||
issueAchievement(player, "buildQArmor");
|
||||
}
|
||||
for(GT_Recipe recipe: GT_Recipe.GT_Recipe_Map.sAssemblylineFakeRecipes.mRecipeList){
|
||||
if(recipe.getOutput(0).getUnlocalizedName().equals(stack.getUnlocalizedName())) {
|
||||
issueAchievement(player, recipe.getOutput(0).getUnlocalizedName());
|
||||
recipe.mHidden=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue