Java tutorial
/** * This class was created by <Vazkii>. It's distributed as * part of the Machinery Craft Mod. Get the Source Code in github: * https://github.com/Professorvennie/MachineryCraft * * Machinery Craft is Open Source and distributed under a * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) * */ package com.professorvennie.machinerycraft.client.gui.pages; import com.professorvennie.machinerycraft.api.book.BookPage; import com.professorvennie.machinerycraft.api.book.IGuiBookEntry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; public class PageImage extends BookPage { ResourceLocation resource; public PageImage(String unlocalizedName, String resource) { super(unlocalizedName); this.resource = new ResourceLocation(resource); } @Override @SideOnly(Side.CLIENT) public void renderScreen(IGuiBookEntry gui, int mx, int my) { TextureManager render = Minecraft.getMinecraft().renderEngine; render.bindTexture(resource); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1F, 1F, 1F, 1F); ((GuiScreen) gui).drawTexturedModalRect(gui.getLeft(), gui.getTop(), 0, 0, gui.getWidth(), gui.getHeight()); GL11.glDisable(GL11.GL_BLEND); int width = gui.getWidth() - 30; int height = gui.getHeight(); int x = gui.getLeft() + 16; int y = gui.getTop() + height - 40; PageText.renderText(x, y, width, height, getUnlocalizedName()); } }