Starting the challenge system.

This commit is contained in:
Lizbeth Rika committed 2015-06-29 17:14:34 +01:00
1 parent 20e5752a55
commit e602f884f3
12 files changed
+372 -3

No files matched your search

@@ -0,0 +1,27 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Jun 29, 2015, 4:45:25 PM (GMT)]
*/
package vazkii.botania.client.challenge;
import net.minecraft.item.ItemStack;
public class Challenge {
public final String unlocalizedName;
public final ItemStack icon;
public final EnumChallengeLevel level;
public Challenge(String unlocalizedName, ItemStack icon, EnumChallengeLevel level) {
this.unlocalizedName = unlocalizedName;
this.icon = icon;
this.level = level;
}
}
@@ -0,0 +1,30 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Jun 29, 2015, 4:46:16 PM (GMT)]
*/
package vazkii.botania.client.challenge;
public enum EnumChallengeLevel {
EASY("botania.challengelevel.easy"),
NORMAL("botania.challengelevel.normal"),
HARD("botania.challengelevel.hard"),
LUNATIC("botania.challengelevel.lunatic");
String name;
private EnumChallengeLevel(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
@@ -0,0 +1,58 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Jun 29, 2015, 4:44:49 PM (GMT)]
*/
package vazkii.botania.client.challenge;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import vazkii.botania.common.item.ModItems;
import net.minecraft.item.ItemStack;
public final class ModChallenges {
public static final EnumMap<EnumChallengeLevel, List<Challenge>> challenges = new EnumMap(EnumChallengeLevel.class);
public static void init() {
for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants())
challenges.put(level, new ArrayList());
ItemStack icon = new ItemStack(ModItems.lexicon); // TODO
addChallenge(EnumChallengeLevel.EASY, "flowerFarm", icon);
addChallenge(EnumChallengeLevel.EASY, "recordFarm", icon);
addChallenge(EnumChallengeLevel.EASY, "reedFarm", icon);
addChallenge(EnumChallengeLevel.EASY, "cobbleGen", icon);
addChallenge(EnumChallengeLevel.EASY, "pureDaisy", icon);
addChallenge(EnumChallengeLevel.EASY, "orechid", icon);
addChallenge(EnumChallengeLevel.EASY, "battery", icon);
addChallenge(EnumChallengeLevel.NORMAL, "apothecaryRefill", icon);
addChallenge(EnumChallengeLevel.NORMAL, "treeFarm", icon);
addChallenge(EnumChallengeLevel.NORMAL, "fullCropFarm", icon);
addChallenge(EnumChallengeLevel.NORMAL, "animalFarm", icon);
addChallenge(EnumChallengeLevel.NORMAL, "boneMealFarm", icon);
addChallenge(EnumChallengeLevel.HARD, "mobTower", icon);
addChallenge(EnumChallengeLevel.HARD, "entropynniumSetup", icon);
addChallenge(EnumChallengeLevel.HARD, "spectrolusSetup", icon);
addChallenge(EnumChallengeLevel.HARD, "potionBrewer", icon);
addChallenge(EnumChallengeLevel.LUNATIC, "autoQuarry", icon);
addChallenge(EnumChallengeLevel.LUNATIC, "runeCrafter", icon);
addChallenge(EnumChallengeLevel.LUNATIC, "kekimurusSetup", icon);
}
public static void addChallenge(EnumChallengeLevel level, String name, ItemStack icon) {
Challenge c = new Challenge("botania.challenge." + name, icon, level);
challenges.get(level).add(c);
}
}
@@ -38,6 +38,7 @@ import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.lexicon.multiblock.IMultiblockRenderHook;
import vazkii.botania.api.wiki.IWikiProvider;
import vazkii.botania.api.wiki.WikiHooks;
import vazkii.botania.client.challenge.ModChallenges;
import vazkii.botania.client.core.handler.BaubleRenderHandler;
import vazkii.botania.client.core.handler.BotaniaPlayerController;
import vazkii.botania.client.core.handler.BoundTileRenderer;
@@ -170,6 +171,8 @@ public class ClientProxy extends CommonProxy {
@Override
public void init(FMLInitializationEvent event) {
super.init(event);
ModChallenges.init();
FMLCommonHandler.instance().bus().register(new ClientTickHandler());
MinecraftForge.EVENT_BUS.register(new HUDHandler());
@@ -43,6 +43,7 @@ import vazkii.botania.client.gui.GuiBotaniaConfig;
import vazkii.botania.client.gui.lexicon.button.GuiButtonAchievement;
import vazkii.botania.client.gui.lexicon.button.GuiButtonBookmark;
import vazkii.botania.client.gui.lexicon.button.GuiButtonCategory;
import vazkii.botania.client.gui.lexicon.button.GuiButtonChallenges;
import vazkii.botania.client.gui.lexicon.button.GuiButtonHistory;
import vazkii.botania.client.gui.lexicon.button.GuiButtonInvisible;
import vazkii.botania.client.gui.lexicon.button.GuiButtonOptions;
@@ -138,6 +139,7 @@ public class GuiLexicon extends GuiScreen {
if(isMainPage()) {
buttonList.add(new GuiButtonOptions(-1, left - 6, top + 5));
buttonList.add(new GuiButtonAchievement(-2, left - 6, top + 18));
buttonList.add(new GuiButtonChallenges(-3, left - 6, top + 32));
}
}
@@ -267,6 +269,8 @@ public class GuiLexicon extends GuiScreen {
mc.displayGuiScreen(new GuiBotaniaConfig(this));
else if(par1GuiButton.id == -2)
mc.displayGuiScreen(new GuiAchievementsHacky(this, mc.thePlayer.getStatFileWriter()));
else if(par1GuiButton.id == -3)
mc.displayGuiScreen(new GuiLexiconChallengesList());
}
public void handleBookmark(GuiButton par1GuiButton) {
@@ -328,6 +332,10 @@ public class GuiLexicon extends GuiScreen {
boolean isIndex() {
return false;
}
boolean isChallenge() {
return false;
}
boolean isCategoryIndex() {
return true;
@@ -476,7 +484,7 @@ public class GuiLexicon extends GuiScreen {
public static boolean isValidLexiconGui(GuiLexicon gui) {
if(gui == null)
return false;
if(gui.isCategoryIndex())
if(gui.isCategoryIndex() || gui.isChallenge())
return true;
if(gui.isIndex()) {
GuiLexiconIndex indexGui = (GuiLexiconIndex) gui;
@@ -0,0 +1,133 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Jun 29, 2015, 4:24:07 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import vazkii.botania.client.challenge.Challenge;
import vazkii.botania.client.challenge.EnumChallengeLevel;
import vazkii.botania.client.challenge.ModChallenges;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.gui.lexicon.button.GuiButtonBack;
import vazkii.botania.client.gui.lexicon.button.GuiButtonChallengeIcon;
public class GuiLexiconChallengesList extends GuiLexicon implements IParented {
GuiLexicon parent;
GuiButton backButton;
public GuiLexiconChallengesList() {
parent = new GuiLexicon();
title = StatCollector.translateToLocal("botaniamisc.challenges");
}
@Override
public void onInitGui() {
super.onInitGui();
buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2));
int i = 13;
int y = top + 21;
for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) {
int j = 0;
for(Challenge c : ModChallenges.challenges.get(level)) {
buttonList.add(new GuiButtonChallengeIcon(i, left + 20 + (j % 6) * 18, y + (j / 6) * 17, c));
i++;
j++;
}
y += 44;
}
}
@Override
public void drawScreen(int par1, int par2, float par3) {
super.drawScreen(par1, par2, par3);
for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants())
fontRendererObj.drawString(StatCollector.translateToLocal(level.getName()), left + 20, top + 12 + level.ordinal() * 44, 0);
}
@Override
protected void keyTyped(char par1, int par2) {
if(par2 == 14) // Backspace
back();
else if(par2 == 199) { // Home
mc.displayGuiScreen(new GuiLexicon());
ClientTickHandler.notifyPageChange();
}
super.keyTyped(par1, par2);
}
@Override
protected void mouseClicked(int par1, int par2, int par3) {
super.mouseClicked(par1, par2, par3);
if(par3 == 1)
back();
}
@Override
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id >= BOOKMARK_START)
handleBookmark(par1GuiButton);
else
switch(par1GuiButton.id) {
case 12 :
mc.displayGuiScreen(parent);
ClientTickHandler.notifyPageChange();
break;
default :
//int index = par1GuiButton.id + page * 12;
//openEntry(index);
}
}
void back() {
if(backButton.enabled) {
actionPerformed(backButton);
backButton.func_146113_a(mc.getSoundHandler());
}
}
@Override
public void setParent(GuiLexicon gui) {
parent = gui;
}
@Override
boolean isMainPage() {
return false;
}
@Override
String getTitle() {
return title;
}
@Override
boolean isChallenge() {
return true;
}
@Override
boolean isCategoryIndex() {
return false;
}
@Override
public GuiLexicon copy() {
return new GuiLexiconChallengesList();
}
}
@@ -35,7 +35,7 @@ public class GuiButtonAchievement extends GuiButtonLexicon {
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 110 : 99, 191, 11, 11);
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 109 : 98, 191, 11, 11);
List<String> tooltip = new ArrayList();
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("botaniamisc.achievements"));
@@ -0,0 +1,55 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Jun 29, 2015, 5:00:30 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import vazkii.botania.client.challenge.Challenge;
public class GuiButtonChallengeIcon extends GuiButtonLexicon {
Challenge challenge;
public GuiButtonChallengeIcon(int id, int x, int y, Challenge challenge) {
super(id, x, y, 16, 16, "");
this.challenge = challenge;
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_146123_n);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemIntoGUI(par1Minecraft.fontRenderer, par1Minecraft.renderEngine, challenge.icon, xPosition, yPosition);
RenderHelper.disableStandardItemLighting();
GL11.glEnable(GL11.GL_BLEND);
List<String> tooltip = new ArrayList();
tooltip.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal(challenge.unlocalizedName));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
vazkii.botania.client.core.helper.RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip);
}
}
@@ -0,0 +1,48 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Jun 29, 2015, 4:16:09 PM (GMT)]
*/
package vazkii.botania.client.gui.lexicon.button;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.lexicon.GuiLexicon;
public class GuiButtonChallenges extends GuiButtonLexicon {
public GuiButtonChallenges(int id, int x, int y) {
super(id, x, y, 11, 11, "");
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_146123_n);
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 131 : 120, 180, 11, 11);
List<String> tooltip = new ArrayList();
tooltip.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("botaniamisc.challenges"));
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip);
}
}
@@ -35,7 +35,7 @@ public class GuiButtonOptions extends GuiButtonLexicon {
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 110 : 99, 180, 11, 11);
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 109 : 98, 180, 11, 11);
List<String> tooltip = new ArrayList();
for(int i = 0; i < 3; i++)