Auto Format code

This commit is contained in:
modmuss50 2016-10-08 20:46:16 +01:00
parent 112b1657cf
commit 796df6c055
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
503 changed files with 12260 additions and 16291 deletions

View file

@ -1,7 +1,5 @@
package techreborn.manual.pages;
import java.awt.*;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import techreborn.init.ModBlocks;
@ -10,41 +8,39 @@ import techreborn.manual.Reference;
import techreborn.manual.util.ButtonUtil;
import techreborn.manual.util.GuiButtonItemTexture;
public class AdvancedMachines extends TitledPage
{
public AdvancedMachines(String name, PageCollection collection)
{
import java.awt.*;
public class AdvancedMachines extends TitledPage {
public AdvancedMachines(String name, PageCollection collection) {
super(name, false, collection, Reference.ADVANCEDMACHINES_KEY, Color.white.getRGB());
}
@Override
public void initGui()
{
public void initGui() {
buttonList.clear();
ButtonUtil.addBackButton(0, width / 2 - 60, height / 2 + 64, buttonList);
buttonList.add(new GuiButtonItemTexture(1, getXMin() + 10, getYMin() + 20, 0, 46, 100, 20,
new ItemStack(ModBlocks.BlastFurnace), ModBlocks.BlastFurnace.getUnlocalizedName(),
ttl(ModBlocks.BlastFurnace.getLocalizedName())));
new ItemStack(ModBlocks.BlastFurnace), ModBlocks.BlastFurnace.getUnlocalizedName(),
ttl(ModBlocks.BlastFurnace.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(2, getXMin() + 10, getYMin() + 40, 0, 46, 100, 20,
new ItemStack(ModBlocks.industrialSawmill), ModBlocks.industrialSawmill.getUnlocalizedName(),
ttl(ModBlocks.industrialSawmill.getLocalizedName())));
new ItemStack(ModBlocks.industrialSawmill), ModBlocks.industrialSawmill.getUnlocalizedName(),
ttl(ModBlocks.industrialSawmill.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(3, getXMin() + 10, getYMin() + 60, 0, 46, 100, 20,
new ItemStack(ModBlocks.IndustrialElectrolyzer), ModBlocks.IndustrialElectrolyzer.getUnlocalizedName(),
ttl(ModBlocks.IndustrialElectrolyzer.getLocalizedName())));
new ItemStack(ModBlocks.IndustrialElectrolyzer), ModBlocks.IndustrialElectrolyzer.getUnlocalizedName(),
ttl(ModBlocks.IndustrialElectrolyzer.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(4, getXMin() + 10, getYMin() + 80, 0, 46, 100, 20,
new ItemStack(ModBlocks.IndustrialGrinder), ModBlocks.IndustrialGrinder.getUnlocalizedName(),
ttl(ModBlocks.IndustrialGrinder.getLocalizedName())));
new ItemStack(ModBlocks.IndustrialGrinder), ModBlocks.IndustrialGrinder.getUnlocalizedName(),
ttl(ModBlocks.IndustrialGrinder.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(5, getXMin() + 10, getYMin() + 100, 0, 46, 100, 20,
new ItemStack(ModBlocks.ImplosionCompressor), ModBlocks.ImplosionCompressor.getUnlocalizedName(),
ttl(ModBlocks.ImplosionCompressor.getLocalizedName())));
new ItemStack(ModBlocks.ImplosionCompressor), ModBlocks.ImplosionCompressor.getUnlocalizedName(),
ttl(ModBlocks.ImplosionCompressor.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(6, getXMin() + 10, getYMin() + 120, 0, 46, 100, 20,
new ItemStack(ModBlocks.centrifuge), ModBlocks.centrifuge.getUnlocalizedName(),
ttl(ModBlocks.centrifuge.getLocalizedName())));
new ItemStack(ModBlocks.centrifuge), ModBlocks.centrifuge.getUnlocalizedName(),
ttl(ModBlocks.centrifuge.getLocalizedName())));
}
@Override
public void actionPerformed(GuiButton button)
{
public void actionPerformed(GuiButton button) {
if (button.id == 0)
collection.changeActivePage(Reference.pageNames.CONTENTS_PAGE);
if (button.id == 1)

View file

@ -10,11 +10,10 @@ import techreborn.manual.Reference;
import java.io.IOException;
public class BasePage extends GuiScreen
{
public class BasePage extends GuiScreen {
public static final ResourceLocation PAGE_TEXTURE = new ResourceLocation(
"techreborn:textures/manual/gui/manual.png");
"techreborn:textures/manual/gui/manual.png");
private final int xSize = 200;
private final int ySize = 180;
// Name Displayed in the index page
@ -24,93 +23,77 @@ public class BasePage extends GuiScreen
// Name used to reference the page
private String REFERENCE_NAME;
public BasePage()
{
public BasePage() {
}
public BasePage(String referenceName, PageCollection collection)
{
public BasePage(String referenceName, PageCollection collection) {
this.REFERENCE_NAME = referenceName;
this.mc = Minecraft.getMinecraft();
this.collection = collection;
initGui();
}
public BasePage(String referenceName, boolean showInMenue, PageCollection collection)
{
public BasePage(String referenceName, boolean showInMenue, PageCollection collection) {
this(referenceName, collection);
this.hasIndexButton = showInMenue;
}
public int getXMin()
{
public int getXMin() {
return (this.width - xSize) / 2;
}
public void setXMin(int x)
{
public void setXMin(int x) {
this.width = x;
}
public int getYMin()
{
public int getYMin() {
return (this.height - ySize) / 2;
}
public void setYMin(int y)
{
public void setYMin(int y) {
this.height = y;
}
// Unlocalized Index Page Name
public BasePage setIndexName(String unlocalizedName)
{
public BasePage setIndexName(String unlocalizedName) {
this.INDEX_NAME = ttl(unlocalizedName);
return this;
}
public String getReferenceName()
{
public String getReferenceName() {
return REFERENCE_NAME;
}
public void setReferenceName(String name)
{
public void setReferenceName(String name) {
REFERENCE_NAME = name;
}
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
minecraft.renderEngine.bindTexture(PAGE_TEXTURE);
drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, ySize);
}
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
}
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.drawScreen(mouseX + offsetX, mouseY + offsetY, 0);
renderOverlayComponents(minecraft, offsetX, offsetY, mouseX, mouseY);
}
@Override
public void actionPerformed(GuiButton button)
{
public void actionPerformed(GuiButton button) {
if (button.id == 0)
collection.changeActivePage(Reference.pageNames.CONTENTS_PAGE);
}
@Override
public void mouseClicked(int par1, int par2, int par3) throws IOException
{
public void mouseClicked(int par1, int par2, int par3) throws IOException {
super.mouseClicked(par1, par2, par3);
}
// Translate To Local
public String ttl(String unlocalizedName)
{
public String ttl(String unlocalizedName) {
return I18n.translateToLocal(unlocalizedName);
}
}

View file

@ -1,7 +1,5 @@
package techreborn.manual.pages;
import java.awt.*;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import techreborn.init.ModBlocks;
@ -10,38 +8,36 @@ import techreborn.manual.Reference;
import techreborn.manual.util.ButtonUtil;
import techreborn.manual.util.GuiButtonItemTexture;
public class BasicMachinesPage extends TitledPage
{
public BasicMachinesPage(String name, PageCollection collection)
{
import java.awt.*;
public class BasicMachinesPage extends TitledPage {
public BasicMachinesPage(String name, PageCollection collection) {
super(name, false, collection, Reference.BASICMACHINES_KEY, Color.white.getRGB());
}
@Override
public void initGui()
{
public void initGui() {
buttonList.clear();
ButtonUtil.addBackButton(0, width / 2 - 60, height / 2 + 64, buttonList);
buttonList.add(new GuiButtonItemTexture(1, getXMin() + 20, getYMin() + 20, 0, 46, 100, 20,
new ItemStack(ModBlocks.Grinder), ModBlocks.Grinder.getUnlocalizedName(),
ttl(ModBlocks.Grinder.getLocalizedName())));
new ItemStack(ModBlocks.Grinder), ModBlocks.Grinder.getUnlocalizedName(),
ttl(ModBlocks.Grinder.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(2, getXMin() + 20, getYMin() + 40, 0, 46, 100, 20,
new ItemStack(ModBlocks.ElectricFurnace), ModBlocks.ElectricFurnace.getUnlocalizedName(),
ttl(ModBlocks.ElectricFurnace.getLocalizedName())));
new ItemStack(ModBlocks.ElectricFurnace), ModBlocks.ElectricFurnace.getUnlocalizedName(),
ttl(ModBlocks.ElectricFurnace.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(3, getXMin() + 20, getYMin() + 60, 0, 46, 100, 20,
new ItemStack(ModBlocks.AlloySmelter), ModBlocks.AlloySmelter.getUnlocalizedName(),
ttl(ModBlocks.AlloySmelter.getLocalizedName())));
new ItemStack(ModBlocks.AlloySmelter), ModBlocks.AlloySmelter.getUnlocalizedName(),
ttl(ModBlocks.AlloySmelter.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(4, getXMin() + 20, getYMin() + 80, 0, 46, 100, 20,
new ItemStack(ModBlocks.Extractor), ModBlocks.Extractor.getUnlocalizedName(),
ttl(ModBlocks.Extractor.getLocalizedName())));
new ItemStack(ModBlocks.Extractor), ModBlocks.Extractor.getUnlocalizedName(),
ttl(ModBlocks.Extractor.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(5, getXMin() + 20, getYMin() + 100, 0, 46, 100, 20,
new ItemStack(ModBlocks.Compressor), ModBlocks.Compressor.getUnlocalizedName(),
ttl(ModBlocks.Compressor.getLocalizedName())));
new ItemStack(ModBlocks.Compressor), ModBlocks.Compressor.getUnlocalizedName(),
ttl(ModBlocks.Compressor.getLocalizedName())));
}
@Override
public void actionPerformed(GuiButton button)
{
public void actionPerformed(GuiButton button) {
if (button.id == 0)
collection.changeActivePage(Reference.pageNames.CONTENTS_PAGE);
if (button.id == 1)

View file

@ -12,43 +12,38 @@ import techreborn.manual.util.GuiButtonItemTexture;
import java.awt.*;
public class ContentsPage extends TitledPage
{
public ContentsPage(String name, PageCollection collection)
{
public class ContentsPage extends TitledPage {
public ContentsPage(String name, PageCollection collection) {
super(name, false, collection, Reference.CONTENTS_KEY, Color.white.getRGB());
}
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
public void initGui() {
buttonList.clear();
buttonList.add(new GuiButtonItemTexture(0, getXMin() + 20, getYMin() + 20, 0, 46, 100, 20,
ItemPlates.getPlateByName("iron"), Reference.pageNames.GETTINGSTARTED_PAGE,
ttl(Reference.GETTINGSTARTED_KEY)));
ItemPlates.getPlateByName("iron"), Reference.pageNames.GETTINGSTARTED_PAGE,
ttl(Reference.GETTINGSTARTED_KEY)));
buttonList.add(new GuiButtonItemTexture(1, getXMin() + 20, getYMin() + 40, 0, 46, 100, 20,
new ItemStack(ModBlocks.Generator), Reference.pageNames.GENERATINGPOWER_PAGE,
ttl(Reference.GENERATINGPOWER_KEY)));
new ItemStack(ModBlocks.Generator), Reference.pageNames.GENERATINGPOWER_PAGE,
ttl(Reference.GENERATINGPOWER_KEY)));
buttonList.add(new GuiButtonItemTexture(2, getXMin() + 20, getYMin() + 60, 0, 46, 100, 20,
new ItemStack(ModBlocks.ElectricFurnace), Reference.pageNames.BASICMACHINES_PAGE,
ttl(Reference.BASICMACHINES_KEY)));
new ItemStack(ModBlocks.ElectricFurnace), Reference.pageNames.BASICMACHINES_PAGE,
ttl(Reference.BASICMACHINES_KEY)));
buttonList.add(new GuiButtonItemTexture(3, getXMin() + 20, getYMin() + 80, 0, 46, 100, 20,
new ItemStack(ModBlocks.BlastFurnace), Reference.pageNames.ADVANCEDMACHINES_PAGE,
ttl(Reference.ADVANCEDMACHINES_KEY)));
new ItemStack(ModBlocks.BlastFurnace), Reference.pageNames.ADVANCEDMACHINES_PAGE,
ttl(Reference.ADVANCEDMACHINES_KEY)));
buttonList.add(new GuiButtonItemTexture(4, getXMin() + 20, getYMin() + 100, 0, 46, 100, 20,
new ItemStack(ModItems.ironDrill), Reference.pageNames.TOOLS_PAGE, ttl(Reference.TOOLS_KEY)));
new ItemStack(ModItems.ironDrill), Reference.pageNames.TOOLS_PAGE, ttl(Reference.TOOLS_KEY)));
}
@Override
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
}
@Override
public void actionPerformed(GuiButton button)
{
public void actionPerformed(GuiButton button) {
if (button.id == 0)
collection.changeActivePage(Reference.pageNames.GETTINGSTARTED_PAGE);
if (button.id == 1)

View file

@ -28,8 +28,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class CraftingInfoPage extends TitledPage
{
public class CraftingInfoPage extends TitledPage {
public ItemStack result;
public String imageprefix = "techreborn:textures/manual/elements/";
public String backpage;
@ -41,8 +40,7 @@ public class CraftingInfoPage extends TitledPage
private float descriptionScale = 0.66f;
public CraftingInfoPage(String name, PageCollection collection, ItemStack itemStack, String unlocalizedDescription,
String backPage)
{
String backPage) {
super(name, true, collection, itemStack.getUnlocalizedName() + ".name", Color.white.getRGB());
this.result = itemStack;
this.recipe = getFirstRecipeForItem(itemStack);
@ -57,27 +55,21 @@ public class CraftingInfoPage extends TitledPage
}
@Override
public void initGui()
{
public void initGui() {
buttonList.clear();
ButtonUtil.addBackButton(0, width / 2 - 60, height / 2 + 64, buttonList);
}
@Override
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
GL11.glPushMatrix();
if (isSmelting)
{
if (isSmelting) {
renderImage(offsetX + 15, offsetY + 10, "furnacerecipe");
} else
{
if (hasRecipe)
{
renderImage(offsetX + (offsetX/ 2) , offsetY + 10, "craftingtable");
} else
{
} else {
if (hasRecipe) {
renderImage(offsetX + (offsetX / 2), offsetY + 10, "craftingtable");
} else {
drawString(fontRendererObj, "No Crafting Recipe", offsetX + 40, offsetY + 22, Color.black.getRGB());
}
}
@ -85,8 +77,7 @@ public class CraftingInfoPage extends TitledPage
}
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
public void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.drawScreen(minecraft, offsetX, offsetY, mouseX, mouseY);
int relativeMouseX = mouseX + offsetX;
int relativeMouseY = mouseY + offsetY;
@ -97,18 +88,15 @@ public class CraftingInfoPage extends TitledPage
ItemStack tooltip = null;
int i = 0;
for (ItemStack input : recipe)
{
if (input != null)
{
for (ItemStack input : recipe) {
if (input != null) {
int row = (i % 3);
int column = i / 3;
int itemX = offsetX + gridOffsetX + (row * itemBoxSize) - 54;
int itemY = offsetY + gridOffsetY + (column * itemBoxSize) + 2;
drawItemStack(input, itemX, itemY, "");
if (relativeMouseX > itemX - 2 && relativeMouseX < itemX - 2 + itemBoxSize && relativeMouseY > itemY - 2
&& relativeMouseY < itemY - 2 + itemBoxSize)
{
&& relativeMouseY < itemY - 2 + itemBoxSize) {
tooltip = input;
}
}
@ -116,26 +104,22 @@ public class CraftingInfoPage extends TitledPage
}
int itemX = offsetX + (isSmelting ? 92 : 112);
int itemY = offsetY + (isSmelting ? 40 : 38);
if (!hasRecipe)
{
if (!hasRecipe) {
itemX = offsetX + 20;
itemY = offsetY + 18;
}
drawItemStack(result, itemX, itemY, "");
if (relativeMouseX > itemX - 2 && relativeMouseX < itemX - 2 + itemBoxSize && relativeMouseY > itemY - 2
&& relativeMouseY < itemY - 2 + itemBoxSize)
{
&& relativeMouseY < itemY - 2 + itemBoxSize) {
tooltip = result;
}
if (tooltip != null)
{
if (tooltip != null) {
drawItemStackTooltip(tooltip, relativeMouseX, relativeMouseY);
}
}
public void renderImage(int offsetX, int offsetY, String imagename)
{
public void renderImage(int offsetX, int offsetY, String imagename) {
TextureManager render = Minecraft.getMinecraft().renderEngine;
render.bindTexture(new ResourceLocation(imageprefix + imagename + ".png"));
@ -146,8 +130,7 @@ public class CraftingInfoPage extends TitledPage
GL11.glDisable(GL11.GL_BLEND);
}
public void addDescription(Minecraft minecraft, int offsetX, int offsetY)
{
public void addDescription(Minecraft minecraft, int offsetX, int offsetY) {
GL11.glPushMatrix();
if (hasRecipe)
GL11.glTranslated(offsetX + 5, offsetY + 75, 1);
@ -155,12 +138,10 @@ public class CraftingInfoPage extends TitledPage
GL11.glTranslated(offsetX + 5, offsetY + 40, 1);
GL11.glScalef(descriptionScale, descriptionScale, descriptionScale);
int offset = 0;
for (String s : getFormattedText(fontRendererObj))
{
for (String s : getFormattedText(fontRendererObj)) {
if (s == null)
break;
if (s.contains("\\%") && s.substring(0, 2).equals("\\%"))
{
if (s.contains("\\%") && s.substring(0, 2).equals("\\%")) {
s = s.substring(2);
offset += fontRendererObj.FONT_HEIGHT / 2;
}
@ -171,19 +152,15 @@ public class CraftingInfoPage extends TitledPage
}
@SuppressWarnings("unchecked")
public List<String> getFormattedText(FontRenderer fr)
{
if (formattedDescription == null)
{
public List<String> getFormattedText(FontRenderer fr) {
if (formattedDescription == null) {
formattedDescription = new ArrayList<>();
if (Strings.isNullOrEmpty(rawDescription))
{
if (Strings.isNullOrEmpty(rawDescription)) {
formattedDescription = ImmutableList.of();
return formattedDescription;
}
if (!rawDescription.contains("\\n"))
{
if (!rawDescription.contains("\\n")) {
formattedDescription = ImmutableList.copyOf(fr.listFormattedStringToWidth(rawDescription, 370));
return formattedDescription;
}
@ -192,16 +169,14 @@ public class CraftingInfoPage extends TitledPage
String raw = rawDescription;
int escape = 0;
while (raw.contains("\\n"))
{
while (raw.contains("\\n")) {
segments.add(raw.substring(0, raw.indexOf("\\n")));
raw = raw.substring(raw.indexOf("\\n") + 2);
if (!raw.contains("\\n"))
segments.add(raw);
escape++;
if (escape > 100)
{
if (escape > 100) {
break;
}
}
@ -212,8 +187,7 @@ public class CraftingInfoPage extends TitledPage
return formattedDescription;
}
protected void drawItemStackTooltip(ItemStack stack, int x, int y)
{
protected void drawItemStackTooltip(ItemStack stack, int x, int y) {
final Minecraft mc = Minecraft.getMinecraft();
FontRenderer font = Objects.firstNonNull(stack.getItem().getFontRenderer(stack), mc.fontRendererObj);
@ -230,8 +204,7 @@ public class CraftingInfoPage extends TitledPage
drawHoveringText(colored, x, y, font);
}
private void drawItemStack(ItemStack par1ItemStack, int par2, int par3, String par4Str)
{
private void drawItemStack(ItemStack par1ItemStack, int par2, int par3, String par4Str) {
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
this.zLevel = 200.0F;
RenderHelper.enableGUIStandardItemLighting();
@ -246,10 +219,8 @@ public class CraftingInfoPage extends TitledPage
this.zLevel = 0.0F;
}
public void renderItemStack(ItemStack stack, int x, int y)
{
if (stack != null)
{
public void renderItemStack(ItemStack stack, int x, int y) {
if (stack != null) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
@ -262,11 +233,9 @@ public class CraftingInfoPage extends TitledPage
}
@SuppressWarnings("unchecked")
private ItemStack[] getFirstRecipeForItem(ItemStack resultingItem)
{
private ItemStack[] getFirstRecipeForItem(ItemStack resultingItem) {
ItemStack[] recipeItems = new ItemStack[9];
for (IRecipe recipe : CraftingManager.getInstance().getRecipeList())
{
for (IRecipe recipe : CraftingManager.getInstance().getRecipeList()) {
if (recipe == null)
continue;
@ -287,11 +256,9 @@ public class CraftingInfoPage extends TitledPage
Iterator iterator = FurnaceRecipes.instance().getSmeltingList().entrySet().iterator();
Map.Entry entry;
while (iterator.hasNext())
{
while (iterator.hasNext()) {
entry = (Map.Entry) iterator.next();
if (entry.getKey() instanceof ItemStack && ((ItemStack) entry.getValue()).isItemEqual(result))
{
if (entry.getKey() instanceof ItemStack && ((ItemStack) entry.getValue()).isItemEqual(result)) {
isSmelting = true;
recipeItems[0] = (ItemStack) entry.getKey();
}
@ -300,14 +267,11 @@ public class CraftingInfoPage extends TitledPage
return recipeItems;
}
protected ItemStack convertToStack(Object obj)
{
protected ItemStack convertToStack(Object obj) {
ItemStack entry = null;
if (obj instanceof ItemStack)
{
if (obj instanceof ItemStack) {
entry = (ItemStack) obj;
} else if (obj instanceof List)
{
} else if (obj instanceof List) {
@SuppressWarnings("unchecked")
List<ItemStack> list = (List<ItemStack>) obj;
if (list.size() > 0)
@ -323,8 +287,7 @@ public class CraftingInfoPage extends TitledPage
}
@SuppressWarnings("unchecked")
private Object[] getRecipeInput(IRecipe recipe)
{
private Object[] getRecipeInput(IRecipe recipe) {
if (recipe instanceof ShapelessOreRecipe)
return ((ShapelessOreRecipe) recipe).getInput().toArray();
else if (recipe instanceof ShapedOreRecipe)
@ -336,43 +299,34 @@ public class CraftingInfoPage extends TitledPage
return null;
}
private Object[] getShapedOreRecipe(ShapedOreRecipe recipe)
{
try
{
private Object[] getShapedOreRecipe(ShapedOreRecipe recipe) {
try {
Field field = ShapedOreRecipe.class.getDeclaredField("width");
if (field != null)
{
if (field != null) {
field.setAccessible(true);
int width = field.getInt(recipe);
Object[] input = recipe.getInput();
Object[] grid = new Object[9];
for (int i = 0, offset = 0, y = 0; y < 3; y++)
{
for (int x = 0; x < 3; x++, i++)
{
if (x < width && offset < input.length)
{
for (int i = 0, offset = 0, y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++, i++) {
if (x < width && offset < input.length) {
grid[i] = input[offset];
offset++;
} else
{
} else {
grid[i] = null;
}
}
}
return grid;
}
} catch (Exception e)
{
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public void actionPerformed(GuiButton button)
{
public void actionPerformed(GuiButton button) {
if (button.id == 0)
collection.changeActivePage(backpage);
}

View file

@ -1,26 +1,22 @@
package techreborn.manual.pages;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import techreborn.manual.PageCollection;
import techreborn.manual.Reference;
import techreborn.manual.util.ButtonUtil;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class DescriptionPage extends TitledPage
{
public class DescriptionPage extends TitledPage {
public boolean hasImage;
public String secondpage;
public String imageprefix = "techreborn:textures/manual/screenshots/";
@ -28,8 +24,7 @@ public class DescriptionPage extends TitledPage
private List<String> formattedDescription;
private float descriptionScale = 0.88f;
public DescriptionPage(String name, PageCollection collection, boolean hasImage, String secondPage)
{
public DescriptionPage(String name, PageCollection collection, boolean hasImage, String secondPage) {
super(name, false, collection, Reference.GETTINGSTARTED_KEY, Color.white.getRGB());
this.hasImage = hasImage;
this.rawDescription = "techreborn.manual." + this.getReferenceName() + ".description";
@ -37,10 +32,8 @@ public class DescriptionPage extends TitledPage
}
@Override
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
if (hasImage)
{
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
if (hasImage) {
renderImage(offsetX, offsetY);
addDescription(mc, offsetX, offsetY + 60);
} else
@ -48,18 +41,15 @@ public class DescriptionPage extends TitledPage
}
@Override
public void initGui()
{
public void initGui() {
buttonList.clear();
ButtonUtil.addBackButton(0, width / 2 - 60, height / 2 + 64, buttonList);
if (secondpage != null)
{
if (secondpage != null) {
ButtonUtil.addNextButton(1, width / 2 + 40, height / 2 + 64, buttonList);
}
}
public void renderImage(int offsetX, int offsetY)
{
public void renderImage(int offsetX, int offsetY) {
TextureManager render = Minecraft.getMinecraft().renderEngine;
render.bindTexture(new ResourceLocation(imageprefix + this.getReferenceName() + ".png"));
@ -70,18 +60,15 @@ public class DescriptionPage extends TitledPage
GL11.glDisable(GL11.GL_BLEND);
}
public void addDescription(Minecraft minecraft, int offsetX, int offsetY)
{
public void addDescription(Minecraft minecraft, int offsetX, int offsetY) {
GL11.glPushMatrix();
GL11.glTranslated(offsetX + 15, offsetY + 40, 1);
GL11.glScalef(descriptionScale, descriptionScale, descriptionScale);
int offset = 0;
for (String s : getFormattedText(fontRendererObj))
{
for (String s : getFormattedText(fontRendererObj)) {
if (s == null)
break;
if (s.contains("\\%") && s.substring(0, 2).equals("\\%"))
{
if (s.contains("\\%") && s.substring(0, 2).equals("\\%")) {
s = s.substring(2);
offset += fontRendererObj.FONT_HEIGHT / 2;
}
@ -92,19 +79,15 @@ public class DescriptionPage extends TitledPage
}
@SuppressWarnings("unchecked")
public List<String> getFormattedText(FontRenderer fr)
{
if (formattedDescription == null)
{
public List<String> getFormattedText(FontRenderer fr) {
if (formattedDescription == null) {
formattedDescription = new ArrayList<>();
if (Strings.isNullOrEmpty(rawDescription))
{
if (Strings.isNullOrEmpty(rawDescription)) {
formattedDescription = ImmutableList.of();
return formattedDescription;
}
if (!rawDescription.contains("\\n"))
{
if (!rawDescription.contains("\\n")) {
formattedDescription = ImmutableList.copyOf(fr.listFormattedStringToWidth(rawDescription, 130));
return formattedDescription;
}
@ -119,13 +102,11 @@ public class DescriptionPage extends TitledPage
}
@Override
public void actionPerformed(GuiButton button)
{
public void actionPerformed(GuiButton button) {
if (button.id == 0)
collection.changeActivePage(Reference.pageNames.GETTINGSTARTED_PAGE);
if (secondpage != null)
{
if (secondpage != null) {
if (button.id == 1)
collection.changeActivePage(secondpage);
}

View file

@ -1,7 +1,5 @@
package techreborn.manual.pages;
import java.awt.*;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import techreborn.init.ModBlocks;
@ -10,38 +8,36 @@ import techreborn.manual.Reference;
import techreborn.manual.util.ButtonUtil;
import techreborn.manual.util.GuiButtonItemTexture;
public class GeneratingPowerPage extends TitledPage
{
public GeneratingPowerPage(String name, PageCollection collection)
{
import java.awt.*;
public class GeneratingPowerPage extends TitledPage {
public GeneratingPowerPage(String name, PageCollection collection) {
super(name, false, collection, Reference.GENERATINGPOWER_KEY, Color.white.getRGB());
}
@Override
public void initGui()
{
public void initGui() {
buttonList.clear();
ButtonUtil.addBackButton(0, width / 2 - 60, height / 2 + 64, buttonList);
buttonList.add(new GuiButtonItemTexture(1, getXMin() + 20, getYMin() + 20, 0, 46, 100, 20,
new ItemStack(ModBlocks.Generator), ModBlocks.Generator.getUnlocalizedName(),
ttl(ModBlocks.Generator.getLocalizedName())));
new ItemStack(ModBlocks.Generator), ModBlocks.Generator.getUnlocalizedName(),
ttl(ModBlocks.Generator.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(2, getXMin() + 20, getYMin() + 40, 0, 46, 100, 20,
new ItemStack(ModBlocks.thermalGenerator), ModBlocks.thermalGenerator.getUnlocalizedName(),
ttl(ModBlocks.thermalGenerator.getLocalizedName())));
new ItemStack(ModBlocks.thermalGenerator), ModBlocks.thermalGenerator.getUnlocalizedName(),
ttl(ModBlocks.thermalGenerator.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(3, getXMin() + 20, getYMin() + 60, 0, 46, 100, 20,
new ItemStack(ModBlocks.solarPanel), ModBlocks.solarPanel.getUnlocalizedName(),
ttl(ModBlocks.solarPanel.getLocalizedName())));
new ItemStack(ModBlocks.solarPanel), ModBlocks.solarPanel.getUnlocalizedName(),
ttl(ModBlocks.solarPanel.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(4, getXMin() + 20, getYMin() + 80, 0, 46, 100, 20,
new ItemStack(ModBlocks.heatGenerator), ModBlocks.heatGenerator.getUnlocalizedName(),
ttl(ModBlocks.heatGenerator.getLocalizedName())));
new ItemStack(ModBlocks.heatGenerator), ModBlocks.heatGenerator.getUnlocalizedName(),
ttl(ModBlocks.heatGenerator.getLocalizedName())));
buttonList.add(new GuiButtonItemTexture(5, getXMin() + 20, getYMin() + 100, 0, 46, 100, 20,
new ItemStack(ModBlocks.LightningRod), ModBlocks.LightningRod.getUnlocalizedName(),
ttl(ModBlocks.LightningRod.getLocalizedName())));
new ItemStack(ModBlocks.LightningRod), ModBlocks.LightningRod.getUnlocalizedName(),
ttl(ModBlocks.LightningRod.getLocalizedName())));
}
@Override
public void actionPerformed(GuiButton button)
{
public void actionPerformed(GuiButton button) {
if (button.id == 0)
collection.changeActivePage(Reference.pageNames.CONTENTS_PAGE);
if (button.id == 1)

View file

@ -1,7 +1,5 @@
package techreborn.manual.pages;
import java.awt.*;
import net.minecraft.client.gui.GuiButton;
import techreborn.items.ItemParts;
import techreborn.items.ItemPlates;
@ -10,29 +8,27 @@ import techreborn.manual.Reference;
import techreborn.manual.util.ButtonUtil;
import techreborn.manual.util.GuiButtonItemTexture;
public class GettingStartedPage extends TitledPage
{
public GettingStartedPage(String name, PageCollection collection)
{
import java.awt.*;
public class GettingStartedPage extends TitledPage {
public GettingStartedPage(String name, PageCollection collection) {
super(name, false, collection, Reference.GETTINGSTARTED_KEY, Color.white.getRGB());
}
@Override
public void initGui()
{
public void initGui() {
buttonList.clear();
ButtonUtil.addBackButton(0, width / 2 - 60, height / 2 + 64, buttonList);
buttonList.add(new GuiButtonItemTexture(1, getXMin() + 20, getYMin() + 20, 0, 46, 100, 20,
ItemParts.getPartByName("rubberSap"), Reference.pageNames.GETTINGRUBBER_PAGE,
ttl(Reference.GETTINGRUBBER_KEY)));
ItemParts.getPartByName("rubberSap"), Reference.pageNames.GETTINGRUBBER_PAGE,
ttl(Reference.GETTINGRUBBER_KEY)));
buttonList.add(new GuiButtonItemTexture(2, getXMin() + 20, getYMin() + 40, 0, 46, 100, 20,
ItemPlates.getPlateByName("iron"), Reference.pageNames.CRAFTINGPLATES_PAGE,
ttl(Reference.CRAFTINGPLATES_KEY)));
ItemPlates.getPlateByName("iron"), Reference.pageNames.CRAFTINGPLATES_PAGE,
ttl(Reference.CRAFTINGPLATES_KEY)));
}
@Override
public void actionPerformed(GuiButton button)
{
public void actionPerformed(GuiButton button) {
if (button.id == 0)
collection.changeActivePage(Reference.pageNames.CONTENTS_PAGE);
if (button.id == 1)

View file

@ -3,22 +3,19 @@ package techreborn.manual.pages;
import net.minecraft.client.Minecraft;
import techreborn.manual.PageCollection;
public class TitledPage extends BasePage
{
public class TitledPage extends BasePage {
public boolean drawTitle = true;
private String title;
private int colour;
public TitledPage(String name, boolean showInMenue, PageCollection collection, String unlocalizedTitle, int colour)
{
public TitledPage(String name, boolean showInMenue, PageCollection collection, String unlocalizedTitle, int colour) {
super(name, showInMenue, collection);
this.title = unlocalizedTitle;
this.colour = colour;
}
@Override
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
public void renderOverlayComponents(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
if (title == null)
title = INDEX_NAME;
if (drawTitle)

View file

@ -1,7 +1,5 @@
package techreborn.manual.pages;
import java.awt.*;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import techreborn.init.ModItems;
@ -10,54 +8,51 @@ import techreborn.manual.Reference;
import techreborn.manual.util.ButtonUtil;
import techreborn.manual.util.GuiButtonItemTexture;
public class ToolsPage extends TitledPage
{
public ToolsPage(String name, PageCollection collection)
{
import java.awt.*;
public class ToolsPage extends TitledPage {
public ToolsPage(String name, PageCollection collection) {
super(name, false, collection, Reference.TOOLS_KEY, Color.white.getRGB());
}
@Override
public void initGui()
{
public void initGui() {
buttonList.clear();
ButtonUtil.addBackButton(0, width / 2 - 60, height / 2 + 64, buttonList);
ButtonUtil.addNextButton(1, width / 2 + 40, height / 2 + 64, buttonList);
buttonList.add(new GuiButtonItemTexture(2, getXMin() + 20, getYMin() + 20, 0, 46, 100, 20,
new ItemStack(ModItems.ironDrill), ModItems.ironDrill.getUnlocalizedName(),
ttl(ModItems.ironDrill.getUnlocalizedName() + ".name")));
new ItemStack(ModItems.ironDrill), ModItems.ironDrill.getUnlocalizedName(),
ttl(ModItems.ironDrill.getUnlocalizedName() + ".name")));
buttonList.add(new GuiButtonItemTexture(3, getXMin() + 20, getYMin() + 40, 0, 46, 100, 20,
new ItemStack(ModItems.diamondDrill), ModItems.diamondDrill.getUnlocalizedName(),
ttl(ModItems.diamondDrill.getUnlocalizedName() + ".name")));
new ItemStack(ModItems.diamondDrill), ModItems.diamondDrill.getUnlocalizedName(),
ttl(ModItems.diamondDrill.getUnlocalizedName() + ".name")));
buttonList.add(new GuiButtonItemTexture(4, getXMin() + 20, getYMin() + 60, 0, 46, 100, 20,
new ItemStack(ModItems.advancedDrill), ModItems.advancedDrill.getUnlocalizedName(),
ttl(ModItems.advancedDrill.getUnlocalizedName() + ".name")));
new ItemStack(ModItems.advancedDrill), ModItems.advancedDrill.getUnlocalizedName(),
ttl(ModItems.advancedDrill.getUnlocalizedName() + ".name")));
buttonList.add(new GuiButtonItemTexture(5, getXMin() + 20, getYMin() + 80, 0, 46, 100, 20,
new ItemStack(ModItems.ironChainsaw), ModItems.ironChainsaw.getUnlocalizedName(),
ttl(ModItems.ironChainsaw.getUnlocalizedName() + ".name")));
new ItemStack(ModItems.ironChainsaw), ModItems.ironChainsaw.getUnlocalizedName(),
ttl(ModItems.ironChainsaw.getUnlocalizedName() + ".name")));
buttonList.add(new GuiButtonItemTexture(6, getXMin() + 20, getYMin() + 100, 0, 46, 100, 20,
new ItemStack(ModItems.diamondChainsaw), ModItems.diamondChainsaw.getUnlocalizedName(),
ttl(ModItems.diamondChainsaw.getUnlocalizedName() + ".name")));
new ItemStack(ModItems.diamondChainsaw), ModItems.diamondChainsaw.getUnlocalizedName(),
ttl(ModItems.diamondChainsaw.getUnlocalizedName() + ".name")));
buttonList.add(new GuiButtonItemTexture(7, getXMin() + 20, getYMin() + 120, 0, 46, 100, 20,
new ItemStack(ModItems.advancedChainsaw), ModItems.advancedChainsaw.getUnlocalizedName(),
ttl(ModItems.advancedChainsaw.getUnlocalizedName() + ".name")));
new ItemStack(ModItems.advancedChainsaw), ModItems.advancedChainsaw.getUnlocalizedName(),
ttl(ModItems.advancedChainsaw.getUnlocalizedName() + ".name")));
}
@Override
public void actionPerformed(GuiButton button)
{
public void actionPerformed(GuiButton button) {
if (button.id == 0)
collection.changeActivePage(Reference.pageNames.CONTENTS_PAGE);
if (button.id == 1)
{
if (button.id == 1) {
buttonList.clear();
ButtonUtil.addBackButton(0, width / 2 - 60, height / 2 + 64, buttonList);
buttonList.add(new GuiButtonItemTexture(8, getXMin() + 20, getYMin() + 20, 0, 46, 100, 20,
new ItemStack(ModItems.omniTool), ModItems.omniTool.getUnlocalizedName(),
ttl(ModItems.omniTool.getUnlocalizedName() + ".name")));
new ItemStack(ModItems.omniTool), ModItems.omniTool.getUnlocalizedName(),
ttl(ModItems.omniTool.getUnlocalizedName() + ".name")));
buttonList.add(new GuiButtonItemTexture(9, getXMin() + 20, getYMin() + 40, 0, 46, 100, 20,
new ItemStack(ModItems.treeTap), ModItems.treeTap.getUnlocalizedName(),
ttl(ModItems.treeTap.getUnlocalizedName() + ".name")));
new ItemStack(ModItems.treeTap), ModItems.treeTap.getUnlocalizedName(),
ttl(ModItems.treeTap.getUnlocalizedName() + ".name")));
}
if (button.id == 2)
collection.changeActivePage(ModItems.ironDrill.getUnlocalizedName() + ".name");