Quick cleanup.

This commit is contained in:
Vasco Lavos committed 2014-01-17 19:34:55 +00:00
1 parent 3072fa98f4
commit 4b0f475bc8
43 files changed
+247 -240

No files matched your search

+4 -4
View File
@@ -21,27 +21,27 @@ public final class BotaniaAPI {
private static List<LexiconCategory> categories = new ArrayList<LexiconCategory>();
private static List<LexiconEntry> allEntries = new ArrayList<LexiconEntry>();
/**
* The internal method handler in use. Do not overwrite.
* @see IInternalMethodHandler
*/
public static IInternalMethodHandler internalHandler = new DummyMethodHandler();
/**
* Adds a category to the list of registered categories to appear in the Lexicon.
*/
public static void addCategory(LexiconCategory category) {
categories.add(category);
}
/**
* Gets all registered categories.
*/
public static List<LexiconCategory> getAllCategories() {
return categories;
}
/**
* Registers a Lexicon Entry and adds it to the category passed in.
*/
@@ -18,15 +18,15 @@ public final class LexiconCategory {
public final String unlocalizedName;
public final List<LexiconEntry> entries = new ArrayList<LexiconEntry>();
/**
* @param unlocalizedName The unlocalized name of this category. This will be localized by the client display.
*/
public LexiconCategory(String unlocalizedName) {
this.unlocalizedName = unlocalizedName;
}
public String getUnlocalizedName() {
return unlocalizedName;
}
}
}
+6 -6
View File
@@ -20,35 +20,35 @@ import net.minecraft.entity.player.EntityPlayer;
import vazkii.botania.api.page.LexiconPage;
public class LexiconEntry {
public final String unlocalizedName;
public List<LexiconPage> pages = new ArrayList<LexiconPage>();
/**
* @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display.
*/
public LexiconEntry(String unlocalizedName) {
this.unlocalizedName = unlocalizedName;
}
public String getUnlocalizedName() {
return unlocalizedName;
}
/**
* Sets what pages you want this entry to have.
*/
public void setLexiconPages(LexiconPage... pages) {
this.pages.addAll(Arrays.asList(pages));
}
/**
* Adds a page to the list of pages.
*/
public void addPage(LexiconPage page) {
pages.add(page);
}
/**
* Should this entry be displayed in the list of entries?
*/
@@ -20,12 +20,12 @@ public class DummyMethodHandler implements IInternalMethodHandler {
public LexiconPage textPage(String key) {
return dummyPage(key);
}
@Override
public LexiconPage imagePage(String key, String resource) {
return dummyPage(resource);
}
private LexiconPage dummyPage(String key) {
return new PageDummy(key);
}
@@ -24,27 +24,27 @@ public interface IGuiLexiconEntry {
* Gets the entry currently portrayed in this gui.
*/
public LexiconEntry getEntry();
/**
* Gets the current page the lexicon GUI is browsing.
*/
public int getPageOn();
/**
* Gets the leftmost part of the GUI.
*/
public int getLeft();
/**
* Gets the topmost part of the GUI.
*/
public int getTop();
/**
* Gets the GUI's width.
*/
public int getWidth();
/**
* Gets the GUI's height
*/
@@ -23,7 +23,7 @@ import vazkii.botania.api.page.LexiconPage;
public interface IInternalMethodHandler {
public LexiconPage textPage(String key);
public LexiconPage imagePage(String key, String resource);
}
@@ -14,13 +14,13 @@ package vazkii.botania.api.page;
import vazkii.botania.api.internal.IGuiLexiconEntry;
public abstract class LexiconPage {
public String unlocalizedName;
public LexiconPage(String unlocalizedName) {
this.unlocalizedName = unlocalizedName;
}
/**
* Does the rendering for this page.
* @param gui The active GuiScreen
@@ -28,7 +28,7 @@ public abstract class LexiconPage {
* @param my The mouse's relative Y position.
*/
public abstract void renderScreen(IGuiLexiconEntry gui, int mx, int my);
public String getUnlocalizedName() {
return unlocalizedName;
}
@@ -13,31 +13,31 @@ package vazkii.botania.client.core.helper;
public final class FontHelper {
public static boolean isFormatColor(char par0) {
return par0 >= 48 && par0 <= 57 || par0 >= 97 && par0 <= 102 || par0 >= 65 && par0 <= 70;
}
public static boolean isFormatColor(char par0) {
return par0 >= 48 && par0 <= 57 || par0 >= 97 && par0 <= 102 || par0 >= 65 && par0 <= 70;
}
public static boolean isFormatSpecial(char par0) {
return par0 >= 107 && par0 <= 111 || par0 >= 75 && par0 <= 79 || par0 == 114 || par0 == 82;
}
public static boolean isFormatSpecial(char par0) {
return par0 >= 107 && par0 <= 111 || par0 >= 75 && par0 <= 79 || par0 == 114 || par0 == 82;
}
public static String getFormatFromString(String par0Str) {
String s1 = "";
int i = -1;
int j = par0Str.length();
public static String getFormatFromString(String par0Str) {
String s1 = "";
int i = -1;
int j = par0Str.length();
while ((i = par0Str.indexOf(167, i + 1)) != -1) {
if (i < j - 1) {
char c0 = par0Str.charAt(i + 1);
while ((i = par0Str.indexOf(167, i + 1)) != -1) {
if (i < j - 1) {
char c0 = par0Str.charAt(i + 1);
if (isFormatColor(c0))
s1 = "\u00a7" + c0;
else if (isFormatSpecial(c0))
s1 = s1 + "\u00a7" + c0;
}
}
if (isFormatColor(c0))
s1 = "\u00a7" + c0;
else if (isFormatSpecial(c0))
s1 = s1 + "\u00a7" + c0;
}
}
return s1;
}
return s1;
}
}
+48 -45
View File
@@ -43,7 +43,7 @@ public class FXSparkle extends EntityFX
particleMaxAge = 3*m;
multiplier=m;
noClip = false;
this.setSize(0.01F, 0.01F);
setSize(0.01F, 0.01F);
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
@@ -54,43 +54,43 @@ public class FXSparkle extends EntityFX
this(world, d, d1, d2, f, 0f, 0f, 0f, m);
currentColor = type;
switch (type) {
case 0:
case 0:
particleRed=.75f + world.rand.nextFloat()*.25f;
particleGreen=.25f + world.rand.nextFloat()*.25f;
particleBlue=.75f + world.rand.nextFloat()*.25f;
break;
case 1:
case 1:
particleRed=.5f + world.rand.nextFloat()*.3f;
particleGreen=.5f + world.rand.nextFloat()*.3f;
particleBlue=.2f;
break;
case 2:
case 2:
particleRed=.2f;
particleGreen=.2f;
particleBlue=.7f + world.rand.nextFloat()*.3f;
break;
case 3:
case 3:
particleRed=.2f;
particleGreen=.7f + world.rand.nextFloat()*.3f;
particleBlue=.2f;
break;
case 4:
case 4:
particleRed=.7f + world.rand.nextFloat()*.3f;
particleGreen=.2f;
particleBlue=.2f;
break;
case 5:
case 5:
blendmode=771;
particleRed= world.rand.nextFloat()*.1f;
particleGreen= world.rand.nextFloat()*.1f;
particleBlue= world.rand.nextFloat()*.1f;
break;
case 6:
case 6:
particleRed= .8f+world.rand.nextFloat()*.2f;
particleGreen= .8f+world.rand.nextFloat()*.2f;
particleBlue= .8f+world.rand.nextFloat()*.2f;
break;
case 7:
case 7:
particleRed=.2f;
particleGreen=.5f + world.rand.nextFloat()*.3f;
particleBlue=.6f + world.rand.nextFloat()*.3f;
@@ -113,6 +113,7 @@ public class FXSparkle extends EntityFX
motionZ = dz / particleMaxAge;
}
@Override
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5)
{
@@ -129,25 +130,25 @@ public class FXSparkle extends EntityFX
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
int part = particle + particleAge/multiplier;
float var8 = (float)(part % 8) / 8.0F;
float var8 = part % 8 / 8.0F;
float var9 = var8 + 0.0624375F*2;
float var10 = (float)(part / 8) / 8.0F;
float var10 = part / 8 / 8.0F;
float var11 = var10 + 0.0624375F*2;
float var12 = 0.1F * this.particleScale;
if (shrink) var12 *= ((particleMaxAge-particleAge+1)/(float)particleMaxAge);
float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)f - interpPosX);
float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)f - interpPosY);
float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)f - interpPosZ);
float var12 = 0.1F * particleScale;
if (shrink) var12 *= (particleMaxAge-particleAge+1)/(float)particleMaxAge;
float var13 = (float)(prevPosX + (posX - prevPosX) * f - interpPosX);
float var14 = (float)(prevPosY + (posY - prevPosY) * f - interpPosY);
float var15 = (float)(prevPosZ + (posZ - prevPosZ) * f - interpPosZ);
float var16 = 1.0F;
tessellator.startDrawingQuads();
tessellator.setBrightness(0x0000f0);
tessellator.setColorRGBA_F(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16, 1);
tessellator.addVertexWithUV((double)(var13 - f1 * var12 - f4 * var12), (double)(var14 - f2 * var12), (double)(var15 - f3 * var12 - f5 * var12), (double)var9, (double)var11);
tessellator.addVertexWithUV((double)(var13 - f1 * var12 + f4 * var12), (double)(var14 + f2 * var12), (double)(var15 - f3 * var12 + f5 * var12), (double)var9, (double)var10);
tessellator.addVertexWithUV((double)(var13 + f1 * var12 + f4 * var12), (double)(var14 + f2 * var12), (double)(var15 + f3 * var12 + f5 * var12), (double)var8, (double)var10);
tessellator.addVertexWithUV((double)(var13 + f1 * var12 - f4 * var12), (double)(var14 - f2 * var12), (double)(var15 + f3 * var12 - f5 * var12), (double)var8, (double)var11);
tessellator.setColorRGBA_F(particleRed * var16, particleGreen * var16, particleBlue * var16, 1);
tessellator.addVertexWithUV(var13 - f1 * var12 - f4 * var12, var14 - f2 * var12, var15 - f3 * var12 - f5 * var12, var9, var11);
tessellator.addVertexWithUV(var13 - f1 * var12 + f4 * var12, var14 + f2 * var12, var15 - f3 * var12 + f5 * var12, var9, var10);
tessellator.addVertexWithUV(var13 + f1 * var12 + f4 * var12, var14 + f2 * var12, var15 + f3 * var12 + f5 * var12, var8, var10);
tessellator.addVertexWithUV(var13 + f1 * var12 - f4 * var12, var14 - f2 * var12, var15 + f3 * var12 - f5 * var12, var8, var11);
tessellator.draw();
@@ -160,6 +161,7 @@ public class FXSparkle extends EntityFX
}
@Override
public void onUpdate()
{
// if (!leyLineEffect) {
@@ -184,8 +186,8 @@ public class FXSparkle extends EntityFX
motionY -= 0.040000000000000001D * (double)particleGravity;
if (noClip==false) pushOutOfBlocks(this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ);
motionY -= 0.040000000000000001D * particleGravity;
if (noClip==false) pushOutOfBlocks(posX, (boundingBox.minY + boundingBox.maxY) / 2.0D, posZ);
// moveEntity(motionX, motionY, motionZ);
posX+=motionX;
posY+=motionY;
@@ -203,10 +205,10 @@ public class FXSparkle extends EntityFX
if (leyLineEffect) {
FXSparkle fx = new FXSparkle(worldObj,
prevPosX+(worldObj.rand.nextFloat()-worldObj.rand.nextFloat())*.1f,
prevPosY+(worldObj.rand.nextFloat()-worldObj.rand.nextFloat())*.1f,
prevPosZ+(worldObj.rand.nextFloat()-worldObj.rand.nextFloat())*.1f,
FXSparkle fx = new FXSparkle(worldObj,
prevPosX+(worldObj.rand.nextFloat()-worldObj.rand.nextFloat())*.1f,
prevPosY+(worldObj.rand.nextFloat()-worldObj.rand.nextFloat())*.1f,
prevPosZ+(worldObj.rand.nextFloat()-worldObj.rand.nextFloat())*.1f,
1f, currentColor, 3+worldObj.rand.nextInt(3));
fx.noClip=true;
FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx);
@@ -217,23 +219,24 @@ public class FXSparkle extends EntityFX
particleGravity = value;
}
@Override
protected boolean pushOutOfBlocks(double par1, double par3, double par5)
{
int var7 = MathHelper.floor_double(par1);
int var8 = MathHelper.floor_double(par3);
int var9 = MathHelper.floor_double(par5);
double var10 = par1 - (double)var7;
double var12 = par3 - (double)var8;
double var14 = par5 - (double)var9;
double var10 = par1 - var7;
double var12 = par3 - var8;
double var14 = par5 - var9;
if (!this.worldObj.isAirBlock(var7, var8, var9))
if (!worldObj.isAirBlock(var7, var8, var9))
{
boolean var16 = !this.worldObj.isBlockNormalCube(var7 - 1, var8, var9);
boolean var17 = !this.worldObj.isBlockNormalCube(var7 + 1, var8, var9);
boolean var18 = !this.worldObj.isBlockNormalCube(var7, var8 - 1, var9);
boolean var19 = !this.worldObj.isBlockNormalCube(var7, var8 + 1, var9);
boolean var20 = !this.worldObj.isBlockNormalCube(var7, var8, var9 - 1);
boolean var21 = !this.worldObj.isBlockNormalCube(var7, var8, var9 + 1);
boolean var16 = !worldObj.isBlockNormalCube(var7 - 1, var8, var9);
boolean var17 = !worldObj.isBlockNormalCube(var7 + 1, var8, var9);
boolean var18 = !worldObj.isBlockNormalCube(var7, var8 - 1, var9);
boolean var19 = !worldObj.isBlockNormalCube(var7, var8 + 1, var9);
boolean var20 = !worldObj.isBlockNormalCube(var7, var8, var9 - 1);
boolean var21 = !worldObj.isBlockNormalCube(var7, var8, var9 + 1);
byte var22 = -1;
double var23 = 9999.0D;
@@ -273,42 +276,42 @@ public class FXSparkle extends EntityFX
var22 = 5;
}
float var25 = this.rand.nextFloat() * 0.05F + 0.025F;
float var26 = (this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F;
float var25 = rand.nextFloat() * 0.05F + 0.025F;
float var26 = (rand.nextFloat() - rand.nextFloat()) * 0.1F;
if (var22 == 0)
{
this.motionX = (double)(-var25);
motionX = -var25;
motionY=motionZ=var26;
}
if (var22 == 1)
{
this.motionX = (double)var25;
motionX = var25;
motionY=motionZ=var26;
}
if (var22 == 2)
{
this.motionY = (double)(-var25);
motionY = -var25;
motionX=motionZ=var26;
}
if (var22 == 3)
{
this.motionY = (double)var25;
motionY = var25;
motionX=motionZ=var26;
}
if (var22 == 4)
{
this.motionZ = (double)(-var25);
motionZ = -var25;
motionY=motionX=var26;
}
if (var22 == 5)
{
this.motionZ = (double)var25;
motionZ = var25;
motionY=motionX=var26;
}
+19 -17
View File
@@ -52,7 +52,7 @@ public class FXWisp extends EntityFX
moteHalfLife = particleMaxAge / 2;
noClip = false;
this.setSize(0.01F, 0.01F);
setSize(0.01F, 0.01F);
EntityLivingBase renderentity = FMLClientHandler.instance().getClient().renderViewEntity;
int visibleDistance = 50;
if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics) visibleDistance=25;
@@ -68,43 +68,43 @@ public class FXWisp extends EntityFX
this(world, d, d1, d2, f, 0f, 0f, 0f);
switch (type) {
case 0:
case 0:
particleRed=.75f + world.rand.nextFloat()*.25f;
particleGreen=.25f + world.rand.nextFloat()*.25f;
particleBlue=.75f + world.rand.nextFloat()*.25f;
break;
case 1:
case 1:
particleRed=.5f + world.rand.nextFloat()*.3f;
particleGreen=.5f + world.rand.nextFloat()*.3f;
particleBlue=.2f;
break;
case 2:
case 2:
particleRed=.2f;
particleGreen=.2f;
particleBlue=.7f + world.rand.nextFloat()*.3f;
break;
case 3:
case 3:
particleRed=.2f;
particleGreen=.7f + world.rand.nextFloat()*.3f;
particleBlue=.2f;
break;
case 4:
case 4:
particleRed=.7f + world.rand.nextFloat()*.3f;
particleGreen=.2f;
particleBlue=.2f;
break;
case 5:
case 5:
blendmode=771;
particleRed= world.rand.nextFloat()*.1f;
particleGreen= world.rand.nextFloat()*.1f;
particleBlue= world.rand.nextFloat()*.1f;
break;
case 6:
case 6:
particleRed= .8f+world.rand.nextFloat()*.2f;
particleGreen= .8f+world.rand.nextFloat()*.2f;
particleBlue= .8f+world.rand.nextFloat()*.2f;
break;
case 7:
case 7:
particleRed=.7f + world.rand.nextFloat()*.3f;
particleGreen=.5f + world.rand.nextFloat()*.2f;
particleBlue=.3f + world.rand.nextFloat()*.1f;
@@ -143,6 +143,7 @@ public class FXWisp extends EntityFX
}
}
@Override
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5)
{
@@ -150,14 +151,14 @@ public class FXWisp extends EntityFX
float agescale = 0;
if (shrink) {
agescale = ((float)particleMaxAge-(float)particleAge) / (float)particleMaxAge;
agescale = ((float)particleMaxAge-(float)particleAge) / particleMaxAge;
} else {
agescale = (float)particleAge / (float)moteHalfLife;
if (agescale>1f) agescale = 2-agescale;
}
this.particleScale = moteParticleScale * agescale;
particleScale = moteParticleScale * agescale;
tessellator.draw();
GL11.glPushMatrix();
@@ -173,9 +174,9 @@ public class FXWisp extends EntityFX
float f10 = 0.5F * particleScale;
float f11 = (float)((prevPosX + (posX - prevPosX) * (double)f) - interpPosX);
float f12 = (float)((prevPosY + (posY - prevPosY) * (double)f) - interpPosY);
float f13 = (float)((prevPosZ + (posZ - prevPosZ) * (double)f) - interpPosZ);
float f11 = (float)(prevPosX + (posX - prevPosX) * f - interpPosX);
float f12 = (float)(prevPosY + (posY - prevPosY) * f - interpPosY);
float f13 = (float)(prevPosZ + (posZ - prevPosZ) * f - interpPosZ);
tessellator.startDrawingQuads();
@@ -183,9 +184,9 @@ public class FXWisp extends EntityFX
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 0.5F);
tessellator.addVertexWithUV(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10, 0, 1);
tessellator.addVertexWithUV((f11 - f1 * f10) + f4 * f10, f12 + f2 * f10, (f13 - f3 * f10) + f5 * f10, 1, 1);
tessellator.addVertexWithUV(f11 - f1 * f10 + f4 * f10, f12 + f2 * f10, f13 - f3 * f10 + f5 * f10, 1, 1);
tessellator.addVertexWithUV(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10, 1, 0);
tessellator.addVertexWithUV((f11 + f1 * f10) - f4 * f10, f12 - f2 * f10, (f13 + f3 * f10) - f5 * f10, 0, 0);
tessellator.addVertexWithUV(f11 + f1 * f10 - f4 * f10, f12 - f2 * f10, f13 + f3 * f10 - f5 * f10, 0, 0);
tessellator.draw();
@@ -197,6 +198,7 @@ public class FXWisp extends EntityFX
tessellator.startDrawingQuads();
}
@Override
public void onUpdate()
{
@@ -215,7 +217,7 @@ public class FXWisp extends EntityFX
}
motionY -= 0.040000000000000001D * (double)particleGravity;
motionY -= 0.040000000000000001D * particleGravity;
// moveEntity(motionX, motionY, motionZ);
posX+=motionX;
posY+=motionY;
@@ -29,17 +29,17 @@ import vazkii.botania.common.item.ModItems;
public class GuiLexicon extends GuiScreen {
public static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_LEXICON);
int guiWidth = 146;
int guiHeight = 180;
int left, top;
@Override
public void initGui() {
super.initGui();
left = width / 2 - guiWidth / 2;
top = height / 2 - guiHeight / 2;
buttonList.clear();
if(isIndex()) {
int x = 18;
@@ -50,47 +50,47 @@ public class GuiLexicon extends GuiScreen {
populateIndex();
}
}
@Override
public void drawScreen(int par1, int par2, float par3) {
public void drawScreen(int par1, int par2, float par3) {
GL11.glColor4f(1F, 1F, 1F, 1F);
mc.renderEngine.bindTexture(texture);
drawTexturedModalRect(left, top, 0, 0, guiWidth, guiHeight);
drawCenteredString(fontRenderer, getTitle(), left + guiWidth / 2, top - 12, 0x00FF00);
drawHeader();
super.drawScreen(par1, par2, par3);
}
void drawHeader() {
boolean unicode = fontRenderer.getUnicodeFlag();
fontRenderer.setUnicodeFlag(true);
fontRenderer.drawSplitString(StatCollector.translateToLocal("botania.gui.lexicon.header"), left + 15, top + 20, 110, 0);
fontRenderer.setUnicodeFlag(unicode);
}
@Override
protected void actionPerformed(GuiButton par1GuiButton) {
int i = par1GuiButton.id - 3;
if(i < 0)
return;
List<LexiconCategory> categoryList = BotaniaAPI.getAllCategories();
LexiconCategory category = i >= categoryList.size() ? null : categoryList.get(i);
if(category != null)
mc.displayGuiScreen(new GuiLexiconIndex(category));
}
String getTitle() {
return ModItems.lexicon.getItemDisplayName(null);
}
boolean isIndex() {
return true;
}
void populateIndex() {
List<LexiconCategory> categoryList = BotaniaAPI.getAllCategories();
for(int i = 3; i < 12; i++) {
@@ -102,5 +102,5 @@ public class GuiLexicon extends GuiScreen {
else button.displayString = "";
}
}
}
@@ -27,50 +27,50 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry {
String title;
GuiButton leftButton, rightButton;
public GuiLexiconEntry(LexiconEntry entry, GuiLexiconIndex index) {
this.entry = entry;
this.index = index;
title = StatCollector.translateToLocal(entry.getUnlocalizedName());
}
@Override
public void initGui() {
super.initGui();
buttonList.add(new GuiButtonBack(0, left + guiWidth / 2 - 8, top + guiHeight + 2));
buttonList.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false));
buttonList.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true));
updatePageButtons();
}
@Override
public LexiconEntry getEntry() {
return entry;
}
@Override
public int getPageOn() {
return page;
}
@Override
boolean isIndex() {
return false;
}
@Override
void drawHeader() {
// NO-OP
}
@Override
String getTitle() {
return String.format("%s (%s/%s)", title, (page + 1), entry.pages.size());
return String.format("%s (%s/%s)", title, page + 1, entry.pages.size());
}
@Override
protected void actionPerformed(GuiButton par1GuiButton) {
switch(par1GuiButton.id) {
@@ -80,22 +80,22 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry {
case 1 :
page--;
break;
case 2 :
case 2 :
page++;
break;
}
updatePageButtons();
}
public void updatePageButtons() {
leftButton.enabled = page != 0;
rightButton.enabled = page + 1 < entry.pages.size();
}
@Override
public void drawScreen(int par1, int par2, float par3) {
super.drawScreen(par1, par2, par3);
LexiconPage page = entry.pages.get(this.page);
page.renderScreen(this, par1, par2);
}
@@ -119,5 +119,5 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry {
public int getHeight() {
return guiHeight;
}
}
@@ -25,7 +25,7 @@ public class GuiLexiconIndex extends GuiLexicon {
LexiconCategory category;
String title;
int page = 0;
public GuiLexiconIndex(LexiconCategory category) {
this.category = category;
title = StatCollector.translateToLocal(category.getUnlocalizedName());
@@ -35,18 +35,18 @@ public class GuiLexiconIndex extends GuiLexicon {
void drawHeader() {
// NO-OP
}
@Override
String getTitle() {
return title;
}
@Override
public void initGui() {
super.initGui();
buttonList.add(new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2));
}
@Override
void populateIndex() {
List<LexiconEntry> entryList = category.entries;
@@ -58,7 +58,7 @@ public class GuiLexiconIndex extends GuiLexicon {
else button.displayString = "";
}
}
@Override
protected void actionPerformed(GuiButton par1GuiButton) {
if(par1GuiButton.id == 12)
@@ -67,7 +67,7 @@ public class GuiLexiconIndex extends GuiLexicon {
int index = par1GuiButton.id + page * 12;
if(index >= category.entries.size())
return;
LexiconEntry entry = category.entries.get(index);
mc.displayGuiScreen(new GuiLexiconEntry(entry, this));
}
@@ -11,23 +11,24 @@
*/
package vazkii.botania.client.gui.button;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.gui.GuiLexicon;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
public class GuiButtonBack extends GuiButton {
public GuiButtonBack(int par1, int par2, int par3) {
super(par1, par2, par3, 18, 9, "");
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
field_82253_i = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_82253_i);
int k = getHoverState(field_82253_i);
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, 36, k == 2 ? 180 : 189, 18, 9);
@@ -20,12 +20,12 @@ public class GuiButtonInvisible extends GuiButton {
public GuiButtonInvisible(int par1, int par2, int par3, int par4, int par5, String par6Str) {
super(par1, par2, par3, par4, par5, par6Str);
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
field_82253_i = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_82253_i);
field_82253_i = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_82253_i);
boolean unicode = par1Minecraft.fontRenderer.getUnicodeFlag();
par1Minecraft.fontRenderer.setUnicodeFlag(true);
par1Minecraft.fontRenderer.drawString((k == 2 ? EnumChatFormatting.BOLD : "") + displayString, xPosition/* + (k == 2 ? 5 : 0)*/, yPosition + (height - 8) / 2, 0);
@@ -11,27 +11,28 @@
*/
package vazkii.botania.client.gui.button;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.gui.GuiLexicon;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.gui.GuiLexicon;
public class GuiButtonPage extends GuiButton {
boolean right;
public GuiButtonPage(int par1, int par2, int par3, boolean right) {
super(par1, par2, par3, 18, 10, "");
this.right = right;
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
if(enabled) {
field_82253_i = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_82253_i);
int k = getHoverState(field_82253_i);
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 18 : 0, right ? 180 : 190, 18, 10);
@@ -25,9 +25,9 @@ public final class LibResources {
public static final String EMTPY_TEXTURE = "emptyTexture";
public static final String GUI_LEXICON = PREFIX_GUI + "lexicon.png";
public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png";
public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png";
public static final String MISC_WISP_LARGE = PREFIX_MISC + "wispLarge.png";
public static final String MISC_WISP_SMALL = PREFIX_MISC + "wispSmall.png";
+4 -4
View File
@@ -28,20 +28,20 @@ public class Botania {
@Instance(LibMisc.MOD_ID)
public static Botania instance;
@SidedProxy(serverSide = LibMisc.PROXY_COMMON, clientSide = LibMisc.PROXY_CLIENT)
public static CommonProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
proxy.preInit(event);
}
@EventHandler
public void init(FMLInitializationEvent event) {
proxy.init(event);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
proxy.postInit(event);
@@ -33,7 +33,7 @@ public class BlockMod extends Block {
GameRegistry.registerBlock(this, par1Str);
return super.setUnlocalizedName(par1Str);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
@@ -31,7 +31,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class BlockModFlower extends BlockFlower {
Icon[] icons;
protected BlockModFlower() {
super(LibBlockIDs.idFlower);
setUnlocalizedName(LibBlockNames.FLOWER);
@@ -39,19 +39,19 @@ public class BlockModFlower extends BlockFlower {
setStepSound(soundGrassFootstep);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
}
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) {
for(int i = 0; i < 16; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public Block setUnlocalizedName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockModFlower.class, par1Str);
return super.setUnlocalizedName(par1Str);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
@@ -64,7 +64,7 @@ public class BlockModFlower extends BlockFlower {
public Icon getIcon(int par1, int par2) {
return icons[par2];
}
@Override
public int damageDropped(int par1) {
return par1;
@@ -16,9 +16,9 @@ import net.minecraft.block.Block;
public final class ModBlocks {
public static Block flower;
public static void init() {
flower = new BlockModFlower();
}
}
@@ -25,25 +25,25 @@ public final class BotaniaCreativeTab extends CreativeTabs {
public static BotaniaCreativeTab INSTANCE = new BotaniaCreativeTab();
List list;
public BotaniaCreativeTab() {
super(LibMisc.MOD_ID);
}
@Override
public ItemStack getIconItemStack() {
return new ItemStack(ModBlocks.flower);
}
@Override
public void displayAllReleventItems(List list) {
this.list = list;
addBlock(ModBlocks.flower);
addItem(ModItems.lexicon);
}
private void addItem(Item item) {
item.getSubItems(item.itemID, this, list);
}
@@ -25,15 +25,15 @@ public final class ConfigHandler {
public static void loadConfig(File configFile) {
config = new Configuration(configFile);
config.load();
// Block IDs
LibBlockIDs.idFlower = loadBlock(LibBlockNames.FLOWER, LibBlockIDs.idFlower);
// Item IDs
LibItemIDs.idLexicon = loadItem(LibItemNames.LEXICON, LibItemIDs.idLexicon);
config.save();
}
@@ -22,7 +22,7 @@ public class InternalMethodHandler implements IInternalMethodHandler {
public LexiconPage textPage(String key) {
return new PageText(key);
}
@Override
public LexiconPage imagePage(String key, String resource) {
return new PageImage(key, resource);
@@ -11,14 +11,14 @@
*/
package vazkii.botania.common.core.helper;
import vazkii.botania.common.lib.LibObfuscation;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.util.ResourceLocation;
import vazkii.botania.common.lib.LibObfuscation;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class ObfuscationHelper {
public static ResourceLocation getParticleTexture() {
return ReflectionHelper.getPrivateValue(EffectRenderer.class, null, LibObfuscation.PARTICLE_TEXTURES);
return ReflectionHelper.getPrivateValue(EffectRenderer.class, null, LibObfuscation.PARTICLE_TEXTURES);
}
}
@@ -28,15 +28,15 @@ public class CommonProxy {
public void preInit(FMLPreInitializationEvent event) {
BotaniaAPI.internalHandler = new InternalMethodHandler();
ConfigHandler.loadConfig(event.getSuggestedConfigurationFile());
ModBlocks.init();
ModItems.init();
LexiconData.init();
}
public void init(FMLInitializationEvent event) {
public void init(FMLInitializationEvent event) {
NetworkRegistry.instance().registerGuiHandler(Botania.instance, new GuiHandler());
}
@@ -27,13 +27,13 @@ public class ItemLexicon extends ItemMod {
setMaxStackSize(1);
setUnlocalizedName(LibItemNames.LEXICON);
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
par3EntityPlayer.openGui(Botania.instance, LibGuiIDs.LEXICON, par2World, 0, 0, 0);
return par1ItemStack;
}
@Override
public EnumRarity getRarity(ItemStack par1ItemStack) {
return EnumRarity.uncommon;
@@ -31,7 +31,7 @@ public class ItemMod extends Item {
GameRegistry.registerItem(this, par1Str);
return super.setUnlocalizedName(par1Str);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) {
@@ -16,9 +16,9 @@ import net.minecraft.item.Item;
public final class ModItems {
public static Item lexicon;
public static void init() {
lexicon = new ItemLexicon();
}
}
@@ -25,5 +25,5 @@ public class ItemBlockModFlower extends ItemBlockWithMetadata {
public String getUnlocalizedName(ItemStack par1ItemStack) {
return super.getUnlocalizedName(par1ItemStack) + par1ItemStack.getItemDamage();
}
}
@@ -22,22 +22,22 @@ public class BLexiconEntry extends LexiconEntry {
super(unlocalizedName);
BotaniaAPI.addEntry(this, category);
}
@Override
public void setLexiconPages(LexiconPage... pages) {
for(LexiconPage page : pages)
page.unlocalizedName = "botania.page." + getLazyUnlocalizedName() + page.unlocalizedName;
super.setLexiconPages(pages);
}
@Override
public String getUnlocalizedName() {
return "botania.entry." + super.getUnlocalizedName();
}
public String getLazyUnlocalizedName() {
return super.getUnlocalizedName();
}
}
@@ -27,7 +27,7 @@ public final class LexiconData {
public static LexiconCategory categoryDevices;
public static LexiconCategory categoryTools;
public static LexiconCategory categoryMisc;
public static void init() {
BotaniaAPI.addCategory(categoryBasics = new LexiconCategory(LibLexicon.CATEGORY_BASICS));
BotaniaAPI.addCategory(categoryEnergy = new LexiconCategory(LibLexicon.CATEGORY_ENERGY));
@@ -37,26 +37,26 @@ public final class LexiconData {
BotaniaAPI.addCategory(categoryMisc = new LexiconCategory(LibLexicon.CATEGORY_MISC));
LexiconEntry entry;
// BASICS ENTRIES
entry = new BLexiconEntry("world", categoryBasics);
entry.setLexiconPages(new PageText("0"), new PageText("1"), new PageImage("2", LibResources.ENTRY_FLOWERS));
entry = new BLexiconEntry("basicConcepts", categoryBasics);
entry.setLexiconPages(new PageText("0"), new PageText("1"));
entry = new BLexiconEntry("gettingStarted", categoryBasics);
entry.setLexiconPages(new PageText("0"));
// ENERGY ENTRIES
// FLOWERS ENTRIES
// DEVICES ENTRIES
// TOOLS ENTRIES
// MISC ENTRIES
}
}
@@ -11,19 +11,20 @@
*/
package vazkii.botania.common.lexicon.page;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.internal.IGuiLexiconEntry;
import vazkii.botania.api.page.LexiconPage;
public class PageImage extends LexiconPage {
ResourceLocation resource;
public PageImage(String unlocalizedName, String resource) {
super(unlocalizedName);
this.resource = new ResourceLocation(resource);
@@ -33,13 +34,13 @@ public class PageImage extends LexiconPage {
public void renderScreen(IGuiLexiconEntry gui, int mx, int my) {
TextureManager render = Minecraft.getMinecraft().renderEngine;
render.bindTexture(resource);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1F, 1F, 1F, 1F);
((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight());
GL11.glDisable(GL11.GL_BLEND);
int width = gui.getWidth() - 30;
int height = gui.getHeight();
int x = gui.getLeft() + 16;
@@ -16,7 +16,6 @@ import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import vazkii.botania.api.internal.IGuiLexiconEntry;
@@ -34,10 +33,10 @@ public class PageText extends LexiconPage {
int width = gui.getWidth() - 30;
int x = gui.getLeft() + 16;
int y = gui.getTop();
renderText(x, y, width, gui.getHeight(), getUnlocalizedName());
}
public static void renderText(int x, int y, int width, int height, String unlocalizedText) {
FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
boolean unicode = renderer.getUnicodeFlag();
@@ -49,35 +48,35 @@ public class PageText extends LexiconPage {
for(String s : textEntries) {
List<String> wrappedLines = new ArrayList();
String workingOn = "";
int i = 0;
String[] tokens = s.split(" ");
for(String s1 : tokens) {
String format = FontHelper.getFormatFromString(s1);
if(MathHelper.stringNullOrLengthZero(format))
format = lastFormat;
if(renderer.getStringWidth(workingOn + " " + s1) >= width) {
wrappedLines.add(workingOn);
workingOn = "";
}
workingOn = workingOn + format + " " + s1;
if(i == tokens.length - 1)
wrappedLines.add(workingOn);
++i;
lastFormat = format;
}
for(String s1 : wrappedLines) {
y += 10;
renderer.drawString(s1, x, y, 0);
}
y += 10;
}
renderer.setUnicodeFlag(unicode);
}
@@ -14,5 +14,5 @@ package vazkii.botania.common.lib;
public final class LibBlockIDs {
public static int idFlower = 1955;
}
@@ -16,5 +16,5 @@ import vazkii.botania.client.lib.LibResources;
public final class LibBlockNames {
public static final String FLOWER = LibResources.PREFIX_MOD + "flower";
}
@@ -14,5 +14,5 @@ package vazkii.botania.common.lib;
public final class LibGuiIDs {
public static final int LEXICON = 0;
}
@@ -14,5 +14,5 @@ package vazkii.botania.common.lib;
public final class LibItemIDs {
public static int idLexicon = 19555;
}
@@ -16,5 +16,5 @@ import vazkii.botania.client.lib.LibResources;
public final class LibItemNames {
public static final String LEXICON = LibResources.PREFIX_MOD + "lexicon";
}
@@ -14,7 +14,7 @@ package vazkii.botania.common.lib;
public final class LibLexicon {
public static final String CATEGORY_PREFIX = "botania.category.";
public static final String CATEGORY_BASICS = CATEGORY_PREFIX + "basics";
public static final String CATEGORY_ENERGY = CATEGORY_PREFIX + "energy";
public static final String CATEGORY_FLOWERS = CATEGORY_PREFIX + "flowers";
@@ -17,12 +17,12 @@ public final class LibMisc {
public static final String MOD_ID = "Botania";
public static final String MOD_NAME = MOD_ID;
public static final String VERSION = "ANT:VERSION-ANT:BUILD";
// Network Contants
public static final String NETWORK_CHANNEL = MOD_ID;
// Proxy Constants
public static final String PROXY_COMMON = "vazkii.botania.common.core.proxy.CommonProxy";
public static final String PROXY_CLIENT = "vazkii.botania.client.core.proxy.ClientProxy";
}
@@ -15,5 +15,5 @@ public final class LibObfuscation {
// EffectRenderer
public static final String[] PARTICLE_TEXTURES = new String[] { "particleTextures", "b", "field_110737_b" };
}
@@ -30,7 +30,7 @@ public class GuiHandler implements IGuiHandler {
case LibGuiIDs.LEXICON :
return new GuiLexicon();
}
return null;
}