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

@ -14,14 +14,12 @@ import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
import techreborn.items.ItemParts;
import techreborn.items.ItemPlates;
import techreborn.manual.loader.ManualLoader;
import techreborn.manual.pages.*;
import java.io.IOException;
@SideOnly(Side.CLIENT)
public class GuiManual extends GuiScreen
{
public class GuiManual extends GuiScreen {
protected final PageCollection root;
public Container inventorySlots;
protected int pageIndex = 0;
@ -30,16 +28,14 @@ public class GuiManual extends GuiScreen
protected int guiLeft;
protected int guiTop;
public GuiManual()
{
public GuiManual() {
this.xSize = 200;
this.ySize = 180;
root = createRoot();
//root = ManualLoader.getPages();
}
protected PageCollection createRoot()
{
protected PageCollection createRoot() {
pageIndex = 0;
final PageCollection pageCollection = new PageCollection();
pageCollection.addPage(new ContentsPage(Reference.pageNames.CONTENTS_PAGE, pageCollection));
@ -48,86 +44,84 @@ public class GuiManual extends GuiScreen
pageCollection.addPage(new GettingStartedPage(Reference.pageNames.GETTINGSTARTED_PAGE, pageCollection));
pageCollection.addPage(new DescriptionPage(Reference.pageNames.GETTINGRUBBER_PAGE, pageCollection, true,
Reference.pageNames.GETTINGRUBBER2_PAGE));
Reference.pageNames.GETTINGRUBBER2_PAGE));
pageCollection.addPage(new CraftingInfoPage(Reference.pageNames.GETTINGRUBBER2_PAGE, pageCollection,
ItemParts.getPartByName("rubber"), "", Reference.pageNames.GETTINGRUBBER_PAGE));
ItemParts.getPartByName("rubber"), "", Reference.pageNames.GETTINGRUBBER_PAGE));
pageCollection.addPage(new CraftingInfoPage(Reference.pageNames.CRAFTINGPLATES_PAGE, pageCollection,
ItemPlates.getPlateByName("iron"), "", Reference.pageNames.GETTINGSTARTED_PAGE));
ItemPlates.getPlateByName("iron"), "", Reference.pageNames.GETTINGSTARTED_PAGE));
// POWER GENERATION
pageCollection.addPage(new GeneratingPowerPage(Reference.pageNames.GENERATINGPOWER_PAGE, pageCollection));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.Generator.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.Generator), "", Reference.pageNames.GENERATINGPOWER_PAGE));
new ItemStack(ModBlocks.Generator), "", Reference.pageNames.GENERATINGPOWER_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.thermalGenerator.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.thermalGenerator), "", Reference.pageNames.GENERATINGPOWER_PAGE));
new ItemStack(ModBlocks.thermalGenerator), "", Reference.pageNames.GENERATINGPOWER_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.solarPanel.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.solarPanel), "", Reference.pageNames.GENERATINGPOWER_PAGE));
new ItemStack(ModBlocks.solarPanel), "", Reference.pageNames.GENERATINGPOWER_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.heatGenerator.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.heatGenerator), "", Reference.pageNames.GENERATINGPOWER_PAGE));
new ItemStack(ModBlocks.heatGenerator), "", Reference.pageNames.GENERATINGPOWER_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.LightningRod.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.LightningRod), "", Reference.pageNames.GENERATINGPOWER_PAGE));
new ItemStack(ModBlocks.LightningRod), "", Reference.pageNames.GENERATINGPOWER_PAGE));
// BASIC MACHINES
pageCollection.addPage(new BasicMachinesPage(Reference.pageNames.BASICMACHINES_PAGE, pageCollection));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.Grinder.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.Grinder), "", Reference.pageNames.BASICMACHINES_PAGE));
new ItemStack(ModBlocks.Grinder), "", Reference.pageNames.BASICMACHINES_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.ElectricFurnace.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.ElectricFurnace), "", Reference.pageNames.BASICMACHINES_PAGE));
new ItemStack(ModBlocks.ElectricFurnace), "", Reference.pageNames.BASICMACHINES_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.AlloySmelter.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.AlloySmelter), "", Reference.pageNames.BASICMACHINES_PAGE));
new ItemStack(ModBlocks.AlloySmelter), "", Reference.pageNames.BASICMACHINES_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.Extractor.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.Extractor), "", Reference.pageNames.BASICMACHINES_PAGE));
new ItemStack(ModBlocks.Extractor), "", Reference.pageNames.BASICMACHINES_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.Compressor.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.Compressor), "", Reference.pageNames.BASICMACHINES_PAGE));
new ItemStack(ModBlocks.Compressor), "", Reference.pageNames.BASICMACHINES_PAGE));
// ADVANCED MACHINES
pageCollection.addPage(new AdvancedMachines(Reference.pageNames.ADVANCEDMACHINES_PAGE, pageCollection));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.BlastFurnace.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.BlastFurnace), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
new ItemStack(ModBlocks.BlastFurnace), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.industrialSawmill.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.industrialSawmill), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
new ItemStack(ModBlocks.industrialSawmill), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.IndustrialElectrolyzer.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.IndustrialElectrolyzer), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
new ItemStack(ModBlocks.IndustrialElectrolyzer), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.IndustrialGrinder.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.IndustrialGrinder), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
new ItemStack(ModBlocks.IndustrialGrinder), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.ImplosionCompressor.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.ImplosionCompressor), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
new ItemStack(ModBlocks.ImplosionCompressor), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModBlocks.centrifuge.getLocalizedName(), pageCollection,
new ItemStack(ModBlocks.centrifuge), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
new ItemStack(ModBlocks.centrifuge), "", Reference.pageNames.ADVANCEDMACHINES_PAGE));
// TOOLS
pageCollection.addPage(new ToolsPage(Reference.pageNames.TOOLS_PAGE, pageCollection));
pageCollection.addPage(new CraftingInfoPage(ModItems.ironDrill.getUnlocalizedName() + ".name", pageCollection,
new ItemStack(ModItems.ironDrill), "", Reference.pageNames.TOOLS_PAGE));
new ItemStack(ModItems.ironDrill), "", Reference.pageNames.TOOLS_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModItems.diamondDrill.getUnlocalizedName() + ".name",
pageCollection, new ItemStack(ModItems.diamondDrill), "", Reference.pageNames.TOOLS_PAGE));
pageCollection, new ItemStack(ModItems.diamondDrill), "", Reference.pageNames.TOOLS_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModItems.advancedDrill.getUnlocalizedName() + ".name",
pageCollection, new ItemStack(ModItems.advancedDrill), "", Reference.pageNames.TOOLS_PAGE));
pageCollection, new ItemStack(ModItems.advancedDrill), "", Reference.pageNames.TOOLS_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModItems.ironChainsaw.getUnlocalizedName() + ".name",
pageCollection, new ItemStack(ModItems.ironChainsaw), "", Reference.pageNames.TOOLS_PAGE));
pageCollection, new ItemStack(ModItems.ironChainsaw), "", Reference.pageNames.TOOLS_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModItems.diamondChainsaw.getUnlocalizedName() + ".name",
pageCollection, new ItemStack(ModItems.diamondChainsaw), "", Reference.pageNames.TOOLS_PAGE));
pageCollection, new ItemStack(ModItems.diamondChainsaw), "", Reference.pageNames.TOOLS_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModItems.advancedChainsaw.getUnlocalizedName() + ".name",
pageCollection, new ItemStack(ModItems.advancedChainsaw), "", Reference.pageNames.TOOLS_PAGE));
pageCollection, new ItemStack(ModItems.advancedChainsaw), "", Reference.pageNames.TOOLS_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModItems.omniTool.getUnlocalizedName() + ".name", pageCollection,
new ItemStack(ModItems.omniTool), "", Reference.pageNames.TOOLS_PAGE));
new ItemStack(ModItems.omniTool), "", Reference.pageNames.TOOLS_PAGE));
pageCollection.addPage(new CraftingInfoPage(ModItems.treeTap.getUnlocalizedName() + ".name", pageCollection,
new ItemStack(ModItems.treeTap), "", Reference.pageNames.TOOLS_PAGE));
new ItemStack(ModItems.treeTap), "", Reference.pageNames.TOOLS_PAGE));
return pageCollection;
}
private int getNextPageIndex()
{
private int getNextPageIndex() {
int i = pageIndex;
pageIndex++;
return i;
}
@Override
public void drawScreen(int mouseX, int mouseY, float par3)
{
public void drawScreen(int mouseX, int mouseY, float par3) {
drawGuiBackgroundLayer(par3, mouseX, mouseY);
super.drawScreen(mouseX, mouseY, par3);
@ -140,24 +134,21 @@ public class GuiManual extends GuiScreen
restoreRenderState();
}
protected void prepareRenderState()
{
protected void prepareRenderState() {
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
}
protected void restoreRenderState()
{
protected void restoreRenderState() {
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableStandardItemLighting();
}
protected void drawGuiBackgroundLayer(float p_146976_1_, int mouseX, int mouseY)
{
protected void drawGuiBackgroundLayer(float p_146976_1_, int mouseX, int mouseY) {
GL11.glPushMatrix();
GL11.glTranslated(this.guiLeft, this.guiTop, 0);
root.renderBackgroundLayer(this.mc, 0, 0, mouseX - this.guiLeft, mouseY - this.guiTop);
@ -165,41 +156,35 @@ public class GuiManual extends GuiScreen
}
@Override
public void setWorldAndResolution(Minecraft minecraft, int x, int y)
{
public void setWorldAndResolution(Minecraft minecraft, int x, int y) {
super.setWorldAndResolution(minecraft, x, y);
root.setWorldAndResolution(minecraft, x, y);
}
@Override
public void actionPerformed(GuiButton button)
{
public void actionPerformed(GuiButton button) {
root.actionPerformed(button);
}
@Override
public void mouseClicked(int par1, int par2, int par3) throws IOException
{
public void mouseClicked(int par1, int par2, int par3) throws IOException {
root.mouseClicked(par1, par2, par3);
}
@Override
public void handleInput() throws IOException
{
public void handleInput() throws IOException {
super.handleInput();
}
@Override
public void initGui()
{
public void initGui() {
super.initGui();
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
}
@Override
public boolean doesGuiPauseGame()
{
public boolean doesGuiPauseGame() {
return false;
}
}

View file

@ -1,82 +1,68 @@
package techreborn.manual;
import java.io.IOException;
import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import techreborn.manual.pages.BasePage;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
public class PageCollection extends Gui
{
public class PageCollection extends Gui {
public final List<BasePage> pages = Lists.newArrayList();
protected int x;
protected int y;
private String ACTIVE_PAGE = Reference.pageNames.CONTENTS_PAGE;
public PageCollection()
{
public PageCollection() {
this.x = 0;
this.y = 0;
}
public void addPage(BasePage page)
{
public void addPage(BasePage page) {
pages.add(page);
}
public BasePage getPageByName(String name)
{
for (BasePage component : pages)
{
if (component.getReferenceName().equals(ACTIVE_PAGE))
{
public BasePage getPageByName(String name) {
for (BasePage component : pages) {
if (component.getReferenceName().equals(ACTIVE_PAGE)) {
return component;
}
}
return null;
}
public BasePage getActivePage()
{
for (BasePage component : pages)
{
if (component.getReferenceName().equals(ACTIVE_PAGE))
{
public BasePage getActivePage() {
for (BasePage component : pages) {
if (component.getReferenceName().equals(ACTIVE_PAGE)) {
return component;
}
}
return null;
}
public final void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
public final void drawScreen(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
if (getActivePage() == null)
return;
getActivePage().drawScreen(minecraft, offsetX, offsetY, mouseX, mouseY);
}
public final void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY)
{
public final void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
if (getActivePage() == null)
return;
getActivePage().renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
}
public void changeActivePage(String newPage)
{
public void changeActivePage(String newPage) {
ACTIVE_PAGE = newPage;
if (getActivePage() == null)
return;
getActivePage().setWorldAndResolution(Minecraft.getMinecraft(), x, y);
}
public void setWorldAndResolution(Minecraft minecraft, int x, int y)
{
public void setWorldAndResolution(Minecraft minecraft, int x, int y) {
if (getActivePage() == null)
return;
getActivePage().setWorldAndResolution(minecraft, x, y);
@ -84,8 +70,7 @@ public class PageCollection extends Gui
this.y = y;
}
protected void actionPerformed(GuiButton button)
{
protected void actionPerformed(GuiButton button) {
if (getActivePage() == null)
return;
getActivePage().actionPerformed(button);
@ -96,8 +81,7 @@ public class PageCollection extends Gui
// getActivePage().mo(par1, par2, par3);
// }
protected void mouseClicked(int par1, int par2, int par3) throws IOException
{
protected void mouseClicked(int par1, int par2, int par3) throws IOException {
if (getActivePage() == null)
return;
getActivePage().mouseClicked(par1, par2, par3);

View file

@ -1,7 +1,6 @@
package techreborn.manual;
public class Reference
{
public class Reference {
public static final String CONTENTS_KEY = "techreborn.manual.contents";
public static final String GETTINGSTARTED_KEY = "techreborn.manual.gettingstarted";
public static final String GENERATINGPOWER_KEY = "techreborn.manual.generatingpower";
@ -12,8 +11,7 @@ public class Reference
public static final String GETTINGRUBBER_KEY = "techreborn.manual.gettingrubber";
public static final String CRAFTINGPLATES_KEY = "techreborn.manual.gettingplates";
public class pageNames
{
public class pageNames {
public static final String CONTENTS_PAGE = "contents";
public static final String BASICMACHINES_PAGE = "basicmachines";

View file

@ -5,10 +5,10 @@ package techreborn.manual.loader;
*/
public class DownloadablePackageInfo {
PackageInfo packageInfo;
PackageInfo packageInfo;
String md5;
String md5;
String fileName;
String fileName;
}

View file

@ -1,21 +1,10 @@
package techreborn.manual.loader;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import reborncore.RebornCore;
import reborncore.common.util.Unzip;
import techreborn.manual.PageCollection;
@ -23,93 +12,95 @@ import techreborn.manual.Reference;
import techreborn.manual.loader.pages.CategoriesPage;
import techreborn.manual.saveFormat.ManualFormat;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
/**
* Created by modmuss50 on 23/04/2016.
*/
public class ManualLoader {
public static final String MANUAL_VERSION = "0";
public static final String MANUAL_VERSION = "0";
File configDir;
File configDir;
public static ManualFormat format;
public static ManualFormat format;
public ManualLoader(File configDir) {
this.configDir = configDir;
}
public ManualLoader(File configDir) {
this.configDir = configDir;
}
VersionsInfo info = null;
VersionsInfo info = null;
public void load() throws IOException {
File manualdir = new File(configDir, "manual");
if (!manualdir.exists()) {
manualdir.mkdir();
}
public void load() throws IOException {
File manualdir = new File(configDir, "manual");
if (!manualdir.exists()) {
manualdir.mkdir();
}
URL url = new URL(RebornCore.WEB_URL + "techreborn/manual/versions.json");
URLConnection con = url.openConnection();
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
Gson gson = new Gson();
info = gson.fromJson(body, new TypeToken<VersionsInfo>() {
}.getType());
URL url = new URL(RebornCore.WEB_URL + "techreborn/manual/versions.json");
URLConnection con = url.openConnection();
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
Gson gson = new Gson();
info = gson.fromJson(body, new TypeToken<VersionsInfo>() {
}.getType());
DownloadablePackageInfo downloadablePackageInfo = null;
DownloadablePackageInfo downloadablePackageInfo = null;
if(info != null){
for(DownloadablePackageInfo packageInfo : info.versions){
if(packageInfo.packageInfo.version.equals(MANUAL_VERSION)){
downloadablePackageInfo = packageInfo;
break;
}
}
}
if (info != null) {
for (DownloadablePackageInfo packageInfo : info.versions) {
if (packageInfo.packageInfo.version.equals(MANUAL_VERSION)) {
downloadablePackageInfo = packageInfo;
break;
}
}
}
if(downloadablePackageInfo != null){
boolean hasIntactZip = false;
File zipLocation = new File(manualdir, downloadablePackageInfo.fileName);
if(zipLocation.exists()){
String md5 = getMD5(zipLocation);
if(md5.equals(downloadablePackageInfo.md5)){
//Oh look we allready have it!
hasIntactZip = true;
}
} else {
FileUtils.copyURLToFile(new URL(RebornCore.WEB_URL + "techreborn/manual/packages/" + downloadablePackageInfo.fileName), zipLocation);
String md5 = getMD5(zipLocation);
if(md5.equals(downloadablePackageInfo.md5)){
//ok the downloaded file is valid
hasIntactZip = true;
}
}
if(hasIntactZip){
File outputDir = new File(manualdir, zipLocation.getName().replace(".zip", ""));
Unzip.unzip(zipLocation, outputDir);
File inputData = new File(outputDir, "master.json");
BufferedReader reader = new BufferedReader(new FileReader(inputData));
ManualLoader.format = gson.fromJson(reader, ManualFormat.class);
}
if (downloadablePackageInfo != null) {
boolean hasIntactZip = false;
File zipLocation = new File(manualdir, downloadablePackageInfo.fileName);
if (zipLocation.exists()) {
String md5 = getMD5(zipLocation);
if (md5.equals(downloadablePackageInfo.md5)) {
//Oh look we allready have it!
hasIntactZip = true;
}
} else {
FileUtils.copyURLToFile(new URL(RebornCore.WEB_URL + "techreborn/manual/packages/" + downloadablePackageInfo.fileName), zipLocation);
String md5 = getMD5(zipLocation);
if (md5.equals(downloadablePackageInfo.md5)) {
//ok the downloaded file is valid
hasIntactZip = true;
}
}
if (hasIntactZip) {
File outputDir = new File(manualdir, zipLocation.getName().replace(".zip", ""));
Unzip.unzip(zipLocation, outputDir);
File inputData = new File(outputDir, "master.json");
BufferedReader reader = new BufferedReader(new FileReader(inputData));
ManualLoader.format = gson.fromJson(reader, ManualFormat.class);
}
}
}
}
}
public static PageCollection getPages(){
final PageCollection pageCollection = new PageCollection();
pageCollection.addPage(new CategoriesPage(Reference.pageNames.CONTENTS_PAGE, pageCollection));
public static PageCollection getPages() {
final PageCollection pageCollection = new PageCollection();
pageCollection.addPage(new CategoriesPage(Reference.pageNames.CONTENTS_PAGE, pageCollection));
return pageCollection;
}
public static String getMD5(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);
String md5 = DigestUtils.md5Hex(fis);
fis.close();
return md5;
}
return pageCollection;
}
public static String getMD5(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);
String md5 = DigestUtils.md5Hex(fis);
fis.close();
return md5;
}
}

View file

@ -5,10 +5,10 @@ package techreborn.manual.loader;
*/
public class PackageInfo {
public String name;
public String name;
public String version;
public String version;
public String language;
public String language;
}

View file

@ -7,10 +7,10 @@ import java.util.List;
*/
public class VersionsInfo {
String name;
String name;
String lastUpdated;
String lastUpdated;
List<DownloadablePackageInfo> versions;
List<DownloadablePackageInfo> versions;
}

View file

@ -2,16 +2,12 @@ package techreborn.manual.loader.pages;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
import techreborn.items.ItemPlates;
import techreborn.manual.PageCollection;
import techreborn.manual.Reference;
import techreborn.manual.loader.ManualLoader;
import techreborn.manual.pages.TitledPage;
import techreborn.manual.saveFormat.Entry;
import techreborn.manual.saveFormat.ManualFormat;
import techreborn.manual.util.GuiButtonItemTexture;
import java.awt.*;
@ -20,71 +16,65 @@ import java.util.ArrayList;
/**
* Created by Mark on 23/04/2016.
*/
public class CategoriesPage extends TitledPage
{
public class CategoriesPage extends TitledPage {
public CategoriesPage(String name, PageCollection collection) {
super(name, false, collection, Reference.CONTENTS_KEY, Color.white.getRGB());
}
public CategoriesPage(String name, PageCollection collection)
{
super(name, false, collection, Reference.CONTENTS_KEY, Color.white.getRGB());
}
@SuppressWarnings("unchecked")
@Override
public void initGui() {
buttonList.clear();
ArrayList<String> categories = new ArrayList<>();
for (Entry entry : ManualLoader.format.entries) {
if (!categories.contains(entry.category)) {
categories.add(entry.category);
}
}
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
buttonList.clear();
ArrayList<String> categories = new ArrayList<>();
for(Entry entry : ManualLoader.format.entries){
if(!categories.contains(entry.category)){
categories.add(entry.category);
}
}
int i = 0;
for (String string : categories) {
buttonList.add(new GuiButtonItemTexture(i, getXMin() + 20, getYMin() + 20 + (i * 20), 0, 46, 100, 20,
ItemPlates.getPlateByName("iron"), string,
string));
i++;
System.out.println(string);
}
//
//
// buttonList.add(new GuiButtonItemTexture(0, getXMin() + 20, getYMin() + 20, 0, 46, 100, 20,
// 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)));
// 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)));
// 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)));
// 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)));
}
int i = 0;
for(String string : categories){
buttonList.add(new GuiButtonItemTexture(i, getXMin() + 20, getYMin() + 20 + (i * 20), 0, 46, 100, 20,
ItemPlates.getPlateByName("iron"), string,
string));
i++;
System.out.println(string);
}
//
//
// buttonList.add(new GuiButtonItemTexture(0, getXMin() + 20, getYMin() + 20, 0, 46, 100, 20,
// 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)));
// 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)));
// 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)));
// 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)));
}
@Override
public void renderBackgroundLayer(Minecraft minecraft, int offsetX, int offsetY, int mouseX, int mouseY) {
super.renderBackgroundLayer(minecraft, offsetX, offsetY, mouseX, mouseY);
}
@Override
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)
{
// if (button.id == 0)
// collection.changeActivePage(Reference.pageNames.GETTINGSTARTED_PAGE);
// if (button.id == 1)
// collection.changeActivePage(Reference.pageNames.GENERATINGPOWER_PAGE);
// if (button.id == 2)
// collection.changeActivePage(Reference.pageNames.BASICMACHINES_PAGE);
// if (button.id == 3)
// collection.changeActivePage(Reference.pageNames.ADVANCEDMACHINES_PAGE);
// if (button.id == 4)
// collection.changeActivePage(Reference.pageNames.TOOLS_PAGE);
}
@Override
public void actionPerformed(GuiButton button) {
// if (button.id == 0)
// collection.changeActivePage(Reference.pageNames.GETTINGSTARTED_PAGE);
// if (button.id == 1)
// collection.changeActivePage(Reference.pageNames.GENERATINGPOWER_PAGE);
// if (button.id == 2)
// collection.changeActivePage(Reference.pageNames.BASICMACHINES_PAGE);
// if (button.id == 3)
// collection.changeActivePage(Reference.pageNames.ADVANCEDMACHINES_PAGE);
// if (button.id == 4)
// collection.changeActivePage(Reference.pageNames.TOOLS_PAGE);
}
}

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");

View file

@ -5,19 +5,18 @@ package techreborn.manual.saveFormat;
*/
public class Entry {
public String name;
public String name;
public String registryName;
public String registryName;
public MetaData meta;
public MetaData meta;
/**
* This says what type of page it is, crafting, image, ect
*
*/
public String type;
/**
* This says what type of page it is, crafting, image, ect
*/
public String type;
public String category;
public String category;
public EntryData data;
public EntryData data;
}

View file

@ -7,9 +7,9 @@ import java.util.HashMap;
*/
public class EntryData {
/**
* Use this to store data for a page
*/
public HashMap<String, String> data;
/**
* Use this to store data for a page
*/
public HashMap<String, String> data;
}

View file

@ -7,18 +7,18 @@ import java.util.List;
*/
public class ManualFormat {
public String name;
public String name;
public String modId;
public String modId;
public List<Entry> entries;
public List<Entry> entries;
public ManualFormat(String name, String modId, List<Entry> entries) {
this.name = name;
this.modId = modId;
this.entries = entries;
}
public ManualFormat(String name, String modId, List<Entry> entries) {
this.name = name;
this.modId = modId;
this.entries = entries;
}
public ManualFormat() {
}
public ManualFormat() {
}
}

View file

@ -5,8 +5,8 @@ package techreborn.manual.saveFormat;
*/
public class MetaData {
int startMeta;
int startMeta;
int endMeta;
int endMeta;
}

View file

@ -1,22 +1,19 @@
package techreborn.manual.util;
import java.util.List;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
@SideOnly(Side.CLIENT)
public class ButtonUtil
{
public class ButtonUtil {
@SideOnly(Side.CLIENT)
public static void addBackButton(int ID, int X, int Y, List buttonList)
{
public static void addBackButton(int ID, int X, int Y, List buttonList) {
buttonList.add(new GuiButtonCustomTexture(ID, X, Y, 50, 60, 17, 12, "button", "", "", 0, 11, 10, 16));
}
@SideOnly(Side.CLIENT)
public static void addNextButton(int ID, int X, int Y, List buttonList)
{
public static void addNextButton(int ID, int X, int Y, List buttonList) {
buttonList.add(new GuiButtonCustomTexture(ID, X, Y, 50, 60, 17, 12, "button", "", "", 0, 1, 10, 17));
}
}

View file

@ -4,27 +4,22 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import org.lwjgl.opengl.GL11;
public class GuiButtonAHeight extends GuiButton
{
public class GuiButtonAHeight extends GuiButton {
public GuiButtonAHeight(int id, int xPos, int yPos, int width, int hight, String displayString)
{
public GuiButtonAHeight(int id, int xPos, int yPos, int width, int hight, String displayString) {
super(id, xPos, yPos, width, hight, displayString);
}
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY)
{
if (this.visible)
{
public void drawButton(Minecraft minecraft, int mouseX, int mouseY) {
if (this.visible) {
FontRenderer fontrenderer = minecraft.fontRendererObj;
minecraft.getTextureManager().bindTexture(BUTTON_TEXTURES);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
&& mouseY < this.yPosition + this.height;
int k = this.getHoverState(this.hovered);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
@ -32,31 +27,27 @@ public class GuiButtonAHeight extends GuiButton
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2,
46 + k * 20, this.width / 2, this.height);
46 + k * 20, this.width / 2, this.height);
if (this.height < 20)
{
if (this.height < 20) {
this.drawTexturedModalRect(xPosition, yPosition + 3, 0, (46 + k * 20) + 20 - height + 3, width / 2,
height - 3);
height - 3);
this.drawTexturedModalRect(xPosition + width / 2, yPosition + 3, 200 - width / 2,
(46 + k * 20) + 20 - height + 3, width / 2, height - 3);
(46 + k * 20) + 20 - height + 3, width / 2, height - 3);
}
this.mouseDragged(minecraft, mouseX, mouseY);
int l = 14737632;
if (packedFGColour != 0)
{
if (packedFGColour != 0) {
l = packedFGColour;
} else if (!this.enabled)
{
} else if (!this.enabled) {
l = 10526880;
} else if (this.hovered)
{
} else if (this.hovered) {
l = 16777120;
}
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2,
this.yPosition + (this.height - 8) / 2, l);
this.yPosition + (this.height - 8) / 2, l);
}
}
}

View file

@ -1,17 +1,15 @@
package techreborn.manual.util;
import java.awt.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.config.GuiButtonExt;
import org.lwjgl.opengl.GL11;
public class GuiButtonCustomTexture extends GuiButtonExt
{
import java.awt.*;
public class GuiButtonCustomTexture extends GuiButtonExt {
public int textureU;
public int textureV;
public String texturename;
@ -26,8 +24,7 @@ public class GuiButtonCustomTexture extends GuiButtonExt
public int textureW;
public GuiButtonCustomTexture(int id, int xPos, int yPos, int u, int v, int buttonWidth, int buttonHeight,
String texturename, String linkedPage, String name, int buttonU, int buttonV, int textureH, int textureW)
{
String texturename, String linkedPage, String name, int buttonU, int buttonV, int textureH, int textureW) {
super(id, xPos, yPos, buttonWidth, buttonHeight, "_");
this.textureU = u;
this.textureV = v;
@ -42,18 +39,15 @@ public class GuiButtonCustomTexture extends GuiButtonExt
this.textureW = textureW;
}
public void drawButton(Minecraft mc, int mouseX, int mouseY)
{
if (this.visible)
{
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
&& mouseY < this.yPosition + this.height;
mc.getTextureManager().bindTexture(BUTTON_TEXTURES);
int u = textureU;
int v = textureV;
if (flag)
{
if (flag) {
u += width;
GL11.glPushMatrix();
GL11.glColor4f(0f, 0f, 0f, 1f);
@ -66,12 +60,11 @@ public class GuiButtonCustomTexture extends GuiButtonExt
RenderHelper.enableGUIStandardItemLighting();
renderImage(this.xPosition, this.yPosition);
this.drawString(mc.fontRendererObj, this.NAME, this.xPosition + 20, this.yPosition + 3,
Color.white.getRGB());
Color.white.getRGB());
}
}
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.texturename + ".png"));
@ -82,8 +75,7 @@ public class GuiButtonCustomTexture extends GuiButtonExt
GL11.glDisable(GL11.GL_BLEND);
}
public boolean getIsHovering()
{
public boolean getIsHovering() {
return hovered;
}
}

View file

@ -9,8 +9,7 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
public class GuiButtonItemTexture extends GuiButtonExt
{
public class GuiButtonItemTexture extends GuiButtonExt {
public int textureU;
public int textureV;
@ -19,8 +18,7 @@ public class GuiButtonItemTexture extends GuiButtonExt
public String NAME;
public GuiButtonItemTexture(int id, int xPos, int yPos, int u, int v, int width, int height, ItemStack stack,
String linkedPage, String name)
{
String linkedPage, String name) {
super(id, xPos, yPos, width, height, "_");
textureU = u;
textureV = v;
@ -29,17 +27,14 @@ public class GuiButtonItemTexture extends GuiButtonExt
this.LINKED_PAGE = linkedPage;
}
public void drawButton(Minecraft mc, int mouseX, int mouseY)
{
if (this.visible)
{
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
if (this.visible) {
boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
&& mouseY < this.yPosition + this.height;
mc.getTextureManager().bindTexture(BUTTON_TEXTURES);
int u = textureU;
int v = textureV;
if (flag)
{
if (flag) {
u += mc.fontRendererObj.getStringWidth(this.NAME) + 25;
v += mc.fontRendererObj.getStringWidth(this.NAME) + 25;
GL11.glPushMatrix();
@ -54,12 +49,11 @@ public class GuiButtonItemTexture extends GuiButtonExt
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
itemRenderer.renderItemIntoGUI(itemstack, this.xPosition, this.yPosition);
this.drawString(mc.fontRendererObj, this.NAME, this.xPosition + 20, this.yPosition + 3,
Color.white.getRGB());
Color.white.getRGB());
}
}
public boolean getIsHovering()
{
public boolean getIsHovering() {
return hovered;
}

View file

@ -1,38 +1,33 @@
package techreborn.manual.util;
import java.awt.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.util.text.TextFormatting;
import org.lwjgl.opengl.GL11;
public class GuiButtonTextOnly extends GuiButton
{
import java.awt.*;
public class GuiButtonTextOnly extends GuiButton {
public String LINKED_PAGE;
public int textColour;
public GuiButtonTextOnly(int id, int xPos, int yPos, int width, int hight, String displayString, String linkedPage,
int colour)
{
int colour) {
super(id, xPos, yPos, width, hight, displayString);
this.LINKED_PAGE = linkedPage;
this.textColour = colour;
}
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY)
{
if (this.visible)
{
public void drawButton(Minecraft minecraft, int mouseX, int mouseY) {
if (this.visible) {
FontRenderer fontrenderer = minecraft.fontRendererObj;
minecraft.getTextureManager().bindTexture(BUTTON_TEXTURES);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
&& mouseY < this.yPosition + this.height;
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
@ -40,11 +35,9 @@ public class GuiButtonTextOnly extends GuiButton
this.mouseDragged(minecraft, mouseX, mouseY);
String trimmedDisplayString = displayString;
if (fontrenderer.getStringWidth(displayString) > width + 30 && !this.hovered)
{
if (fontrenderer.getStringWidth(displayString) > width + 30 && !this.hovered) {
int energencyBreak = 0;
while (fontrenderer.getStringWidth(trimmedDisplayString) * 0.7 > width - 5)
{
while (fontrenderer.getStringWidth(trimmedDisplayString) * 0.7 > width - 5) {
trimmedDisplayString = trimmedDisplayString.substring(0, trimmedDisplayString.length() - 1);
energencyBreak++;
if (energencyBreak > 100)
@ -53,25 +46,23 @@ public class GuiButtonTextOnly extends GuiButton
trimmedDisplayString += "...";
}
if (this.hovered)
{
if (this.hovered) {
trimmedDisplayString = TextFormatting.BOLD + "" + TextFormatting.ITALIC + trimmedDisplayString;
GL11.glPushMatrix();
GL11.glColor4f(0f, 0f, 0f, 1f);
drawTexturedModalRect(xPosition + (int) (xPosition * 0.01), yPosition + (int) (yPosition * 0.01), 0, 46,
(int) (fontrenderer.getStringWidth(trimmedDisplayString) * 0.72) + 2, 8);
(int) (fontrenderer.getStringWidth(trimmedDisplayString) * 0.72) + 2, 8);
GL11.glPopMatrix();
}
GL11.glPushMatrix();
GL11.glScalef(0.7F, 0.7F, 1);
fontrenderer.drawString(trimmedDisplayString, (int) (xPosition * 1.45),
(int) ((yPosition + (height - 8) / 2) * 1.45), Color.WHITE.getRGB());
(int) ((yPosition + (height - 8) / 2) * 1.45), Color.WHITE.getRGB());
GL11.glPopMatrix();
}
}
public boolean getIsHovering()
{
public boolean getIsHovering() {
return hovered;
}
}