mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 11:49:37 +00:00
Quick looks for the lexica botania
This commit is contained in:
1 parent
9c1d552b5b
commit
e1e008bbb8
15 files changed
+197
-18
No files matched your search
@@ -79,6 +79,10 @@ public class LexiconEntry implements Comparable<LexiconEntry> {
|
||||
return unlocalizedName;
|
||||
}
|
||||
|
||||
public String getTagline() {
|
||||
return null; // Override this if you want a tagline. You probably do
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
@@ -119,6 +123,33 @@ public class LexiconEntry implements Comparable<LexiconEntry> {
|
||||
return (priority ? 0 : 1) + StatCollector.translateToLocal(getUnlocalizedName());
|
||||
}
|
||||
|
||||
public List<ItemStack> getDisplayedRecipes() {
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
for(LexiconPage page : pages) {
|
||||
List<ItemStack> l = page.getDisplayedRecipes();
|
||||
|
||||
if(l != null) {
|
||||
ArrayList<ItemStack> itemsAddedThisPage = new ArrayList();
|
||||
|
||||
for(ItemStack s : l) {
|
||||
addItem: {
|
||||
for(ItemStack s1 : itemsAddedThisPage)
|
||||
if(s1.getItem() == s.getItem())
|
||||
break addItem;
|
||||
for(ItemStack s1 : list)
|
||||
if(s1.isItemEqual(s) && ItemStack.areItemStackTagsEqual(s1, s))
|
||||
break addItem;
|
||||
|
||||
itemsAddedThisPage.add(s);
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(LexiconEntry o) {
|
||||
return getNameForSorting().compareTo(o.getNameForSorting());
|
||||
|
||||
@@ -10,7 +10,11 @@
|
||||
*/
|
||||
package vazkii.botania.api.lexicon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -90,6 +94,14 @@ public abstract class LexiconPage {
|
||||
public void onPageAdded(LexiconEntry entry, int index) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the list of recipes present in this page for display in the category
|
||||
* page. Can return null for an entry with no recipes.
|
||||
*/
|
||||
public List<ItemStack> getDisplayedRecipes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName() {
|
||||
return unlocalizedName;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
@API(owner = "Botania", apiVersion = "65", provides = "BotaniaAPI")
|
||||
@API(owner = "Botania", apiVersion = "66", provides = "BotaniaAPI")
|
||||
package vazkii.botania.api;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -144,7 +144,7 @@ public class GuiLexicon extends GuiScreen {
|
||||
int x = 18;
|
||||
for(int i = 0; i < 12; i++) {
|
||||
int y = 16 + i * 12;
|
||||
buttonList.add(new GuiButtonInvisible(this, i, left + x, top + y, 110, 10, ""));
|
||||
buttonList.add(new GuiButtonInvisible((GuiLexiconIndex) this, i, left + x, top + y, 110, 10, ""));
|
||||
}
|
||||
populateIndex();
|
||||
} else if(isCategoryIndex()) {
|
||||
@@ -290,6 +290,10 @@ public class GuiLexicon extends GuiScreen {
|
||||
}
|
||||
|
||||
public void drawBookmark(int x, int y, String s, boolean drawLeft) {
|
||||
drawBookmark(x, y, s, drawLeft, 0x111111);
|
||||
}
|
||||
|
||||
public void drawBookmark(int x, int y, String s, boolean drawLeft, int color) {
|
||||
// This function is called from the buttons so I can't use fontRendererObj
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
boolean unicode = font.getUnicodeFlag();
|
||||
@@ -311,7 +315,7 @@ public class GuiLexicon extends GuiScreen {
|
||||
for(int i = 0; i < l + 6; i++)
|
||||
drawTexturedModalRect(x - l / 2 - 3 + i, y - 1, 60, 180, 1, 11);
|
||||
|
||||
font.drawString(s, x - l / 2 + fontOff, y, 0x111111, false);
|
||||
font.drawString(s, x - l / 2 + fontOff, y, color, false);
|
||||
font.setUnicodeFlag(unicode);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,19 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.ILexicon;
|
||||
@@ -46,7 +51,11 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
GuiButton leftButton, rightButton, backButton;
|
||||
GuiLexicon parent;
|
||||
GuiTextField searchField;
|
||||
|
||||
|
||||
GuiButton currentButton;
|
||||
LexiconEntry currentEntry;
|
||||
float infoTime;
|
||||
|
||||
List<LexiconEntry> entriesToDisplay = new ArrayList();
|
||||
|
||||
public GuiLexiconIndex() {
|
||||
@@ -137,6 +146,13 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
} else button.displayString = "";
|
||||
}
|
||||
}
|
||||
|
||||
public void setHoveredButton(GuiButtonInvisible b) {
|
||||
if(b == null)
|
||||
currentEntry = null;
|
||||
else currentEntry = entriesToDisplay.get(b.id + page * 12);
|
||||
currentButton = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int par1, int par2, float par3) {
|
||||
@@ -154,6 +170,52 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
mc.fontRenderer.drawString(s, left + 120 - mc.fontRenderer.getStringWidth(s), top + guiHeight - 18, 0x666666);
|
||||
mc.fontRenderer.setUnicodeFlag(unicode);
|
||||
}
|
||||
|
||||
float animationTime = 4F;
|
||||
if(isShiftKeyDown()) {
|
||||
if(currentButton != null)
|
||||
infoTime = Math.min(animationTime, infoTime + timeDelta);
|
||||
} else infoTime = Math.max(0, infoTime - timeDelta);
|
||||
|
||||
if(currentButton != null && infoTime > 0) {
|
||||
float fract = infoTime / animationTime;
|
||||
|
||||
int x = currentButton.xPosition;
|
||||
int y = currentButton.yPosition;
|
||||
String s = StatCollector.translateToLocal(currentEntry.getTagline());
|
||||
boolean unicode = mc.fontRenderer.getUnicodeFlag();
|
||||
mc.fontRenderer.setUnicodeFlag(true);
|
||||
int width = mc.fontRenderer.getStringWidth(s);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(x, y, 0);
|
||||
GL11.glScalef(fract, 1F, 1F);
|
||||
Gui.drawRect(12, -30, width + 20, -2, 0x44000000);
|
||||
Gui.drawRect(10, -32, width + 22, -2, 0x44000000);
|
||||
drawBookmark(width / 2 + 16, -8, s, true, 0xFFFFFF);
|
||||
mc.fontRenderer.setUnicodeFlag(unicode);
|
||||
|
||||
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
ItemStack paper = new ItemStack(Items.paper, currentEntry.pages.size());
|
||||
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, paper, 14, -28);
|
||||
RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, paper, 14, -28);
|
||||
|
||||
List<ItemStack> stacks = currentEntry.getDisplayedRecipes();
|
||||
if(stacks.size() > 0) {
|
||||
int spaceForEach = Math.min(18, (width - 30) / stacks.size());
|
||||
for(int i = 0; i < stacks.size(); i++) {
|
||||
ItemStack stack = stacks.get(i);
|
||||
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, 38 + spaceForEach * i, -28);
|
||||
}
|
||||
}
|
||||
|
||||
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
setHoveredButton(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -369,3 +431,4 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
return "category_" + (category == null ? "lexindex" : category.unlocalizedName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,16 +20,16 @@ import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import vazkii.botania.client.core.helper.FontHelper;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexiconIndex;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class GuiButtonInvisible extends GuiButtonLexicon {
|
||||
|
||||
GuiLexicon gui;
|
||||
GuiLexiconIndex gui;
|
||||
public ItemStack displayStack = null;
|
||||
float timeHover = 0;
|
||||
|
||||
public GuiButtonInvisible(GuiLexicon gui, int par1, int par2, int par3, int par4, int par5, String par6Str) {
|
||||
public GuiButtonInvisible(GuiLexiconIndex gui, int par1, int par2, int par3, int par4, int par5, String par6Str) {
|
||||
super(par1, par2, par3, par4, par5, par6Str);
|
||||
this.gui = gui;
|
||||
}
|
||||
@@ -40,10 +40,11 @@ public class GuiButtonInvisible extends GuiButtonLexicon {
|
||||
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
|
||||
int k = getHoverState(field_146123_n);
|
||||
boolean showStack = displayStack != null && !displayString.isEmpty();
|
||||
|
||||
if(!displayString.isEmpty() && k == 2)
|
||||
|
||||
if(!displayString.isEmpty() && k == 2) {
|
||||
timeHover = Math.min(5, timeHover + gui.timeDelta);
|
||||
else timeHover = Math.max(0, timeHover - gui.timeDelta);
|
||||
gui.setHoveredButton(this);
|
||||
} else timeHover = Math.max(0, timeHover - gui.timeDelta);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
|
||||
@@ -40,6 +40,11 @@ public class BLexiconEntry extends LexiconEntry {
|
||||
public String getUnlocalizedName() {
|
||||
return "botania.entry." + super.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTagline() {
|
||||
return "botania.tagline." + super.getUnlocalizedName();
|
||||
}
|
||||
|
||||
public String getLazyUnlocalizedName() {
|
||||
return super.getUnlocalizedName();
|
||||
|
||||
@@ -96,6 +96,13 @@ public class PageBrew extends PageRecipe implements ITwoNamedPage {
|
||||
renderItem(gui, xPos, yPos, stack1, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDisplayedRecipes() {
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
list.add(recipe.getOutput(new ItemStack(ModItems.vial)));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondUnlocalizedName(String name) {
|
||||
text = name;
|
||||
|
||||
@@ -177,4 +177,13 @@ public class PageCraftingRecipe extends PageRecipe {
|
||||
|
||||
renderItemAtGridPos(gui, 2, 0, recipe.getRecipeOutput(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDisplayedRecipes() {
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
for(IRecipe r : recipes)
|
||||
list.add(r.getRecipeOutput());
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package vazkii.botania.common.lexicon.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -107,5 +108,14 @@ public class PageElvenRecipe extends PageRecipe {
|
||||
}
|
||||
++ticksElapsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDisplayedRecipes() {
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
for(RecipeElvenTrade r : recipes)
|
||||
list.add(r.getOutput());
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.lexicon.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -147,4 +148,13 @@ public class PageManaInfusionRecipe extends PageRecipe {
|
||||
++ticksElapsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDisplayedRecipes() {
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
for(RecipeManaInfusion r : recipes)
|
||||
list.add(r.getOutput());
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.lexicon.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,6 +26,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.lexicon.LexiconRecipeMappings;
|
||||
import vazkii.botania.api.recipe.RecipeManaInfusion;
|
||||
import vazkii.botania.api.recipe.RecipePetals;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
@@ -94,6 +96,8 @@ public class PagePetalRecipe<T extends RecipePetals> extends PageRecipe {
|
||||
return new ItemStack(ModBlocks.altar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderManaBar(IGuiLexiconEntry gui, T recipe, int mx, int my) {
|
||||
// NO-OP
|
||||
@@ -110,5 +114,14 @@ public class PagePetalRecipe<T extends RecipePetals> extends PageRecipe {
|
||||
}
|
||||
++ticksElapsed;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDisplayedRecipes() {
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
for(T r : recipes)
|
||||
list.add(r.getOutput());
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -145,4 +145,11 @@ public class PageShedding extends PageEntity {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDisplayedRecipes() {
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
list.add(shedStack);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,9 @@
|
||||
*/
|
||||
package vazkii.botania.common.lexicon.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -84,5 +87,12 @@ public class PageTerrasteel extends PageRecipe {
|
||||
public void onPageAdded(LexiconEntry entry, int index) {
|
||||
LexiconRecipeMappings.map(new ItemStack(ModItems.manaResource, 1, 4), entry, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDisplayedRecipes() {
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
list.add(new ItemStack(ModItems.manaResource, 1, 4));
|
||||
return super.getDisplayedRecipes();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user