Tweaked some things, only code-wise

This commit is contained in:
Ellpeck 2015-12-22 14:55:10 +01:00
parent b5349c2869
commit 44b100758e
14 changed files with 65 additions and 58 deletions

View file

@ -15,7 +15,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.ActuallyAdditions; import ellpeck.actuallyadditions.ActuallyAdditions;
import ellpeck.actuallyadditions.blocks.base.BlockContainerBase; import ellpeck.actuallyadditions.blocks.base.BlockContainerBase;
import ellpeck.actuallyadditions.booklet.EntrySet; import ellpeck.actuallyadditions.booklet.EntrySet;
import ellpeck.actuallyadditions.booklet.page.BookletPage;
import ellpeck.actuallyadditions.inventory.GuiHandler; import ellpeck.actuallyadditions.inventory.GuiHandler;
import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.tile.TileEntityBookletStand; import ellpeck.actuallyadditions.tile.TileEntityBookletStand;
@ -145,7 +144,7 @@ public class BlockBookletStand extends BlockContainerBase implements IHudDisplay
strg1 = set.chapter.getLocalizedName(); strg1 = set.chapter.getLocalizedName();
strg2 = "Page "+set.page.getID(); strg2 = "Page "+set.page.getID();
BookletPage.renderItem(null, set.chapter.displayStack != null ? set.chapter.displayStack : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+10, 1F); AssetUtil.renderStackToGui(set.chapter.displayStack != null ? set.chapter.displayStack : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+10, 1F);
} }
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg1, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+8, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg1, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+8, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg2, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+18, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg2, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+18, StringUtil.DECIMAL_COLOR_WHITE);

View file

@ -72,10 +72,10 @@ public class BlockLavaFactoryController extends BlockContainerBase implements IH
if(factory != null){ if(factory != null){
int state = factory.isMultiblock(); int state = factory.isMultiblock();
if(state == TileEntityLavaFactoryController.NOT_MULTI){ if(state == TileEntityLavaFactoryController.NOT_MULTI){
minecraft.fontRenderer.drawSplitString(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.notPart.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE); StringUtil.drawSplitStringWithShadow(minecraft.fontRenderer, StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.notPart.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE);
} }
else if(state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA){ else if(state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA){
minecraft.fontRenderer.drawSplitString(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.works.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE); StringUtil.drawSplitStringWithShadow(minecraft.fontRenderer, StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.works.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE);
} }
} }
} }

View file

@ -128,17 +128,17 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
int distance = (int)Vec3.createVectorHelper(posHit.blockX, posHit.blockY, posHit.blockZ).distanceTo(Vec3.createVectorHelper(phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ())); int distance = (int)Vec3.createVectorHelper(posHit.blockX, posHit.blockY, posHit.blockZ).distanceTo(Vec3.createVectorHelper(phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ()));
Item item = phantom.getBoundPosition().getItemBlock(); Item item = phantom.getBoundPosition().getItemBlock();
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.getBoundPosition().getBlock(), 1, phantom.getBoundPosition().getMetadata())); String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.getBoundPosition().getBlock(), 1, phantom.getBoundPosition().getMetadata()));
minecraft.fontRenderer.drawSplitString(StringUtil.localizeFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-30, 200, StringUtil.DECIMAL_COLOR_WHITE); StringUtil.drawSplitStringWithShadow(minecraft.fontRenderer, StringUtil.localizeFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-30, 200, StringUtil.DECIMAL_COLOR_WHITE);
if(phantom.isBoundThingInRange()){ if(phantom.isBoundThingInRange()){
minecraft.fontRenderer.drawSplitString(EnumChatFormatting.DARK_GREEN+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, 200, StringUtil.DECIMAL_COLOR_WHITE); StringUtil.drawSplitStringWithShadow(minecraft.fontRenderer, EnumChatFormatting.DARK_GREEN+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE);
} }
else{ else{
minecraft.fontRenderer.drawSplitString(EnumChatFormatting.DARK_RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, 200, StringUtil.DECIMAL_COLOR_WHITE); StringUtil.drawSplitStringWithShadow(minecraft.fontRenderer, EnumChatFormatting.DARK_RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE);
} }
} }
else{ else{
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, StringUtil.DECIMAL_COLOR_WHITE);
} }
} }
} }

View file

@ -67,7 +67,7 @@ public class RenderReconstructorLens extends TileEntitySpecialRenderer{
} }
GL11.glScalef(0.5F, 0.5F, 0.5F); GL11.glScalef(0.5F, 0.5F, 0.5F);
AssetUtil.renderItem(stack, 0); AssetUtil.renderItemInWorld(stack, 0);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }

View file

@ -13,8 +13,8 @@ package ellpeck.actuallyadditions.booklet.button;
import ellpeck.actuallyadditions.booklet.BookletUtils; import ellpeck.actuallyadditions.booklet.BookletUtils;
import ellpeck.actuallyadditions.booklet.EntrySet; import ellpeck.actuallyadditions.booklet.EntrySet;
import ellpeck.actuallyadditions.booklet.GuiBooklet; import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.page.BookletPage;
import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.util.AssetUtil;
import ellpeck.actuallyadditions.util.KeyUtil; import ellpeck.actuallyadditions.util.KeyUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
@ -73,7 +73,7 @@ public class BookmarkButton extends GuiButton{
if(this.assignedEntry.entry != null){ if(this.assignedEntry.entry != null){
GL11.glPushMatrix(); GL11.glPushMatrix();
BookletPage.renderItem(booklet, this.assignedEntry.chapter != null && this.assignedEntry.chapter.displayStack != null ? this.assignedEntry.chapter.displayStack : new ItemStack(InitItems.itemBooklet), this.xPosition+2, this.yPosition+1, 0.725F); AssetUtil.renderStackToGui(this.assignedEntry.chapter != null && this.assignedEntry.chapter.displayStack != null ? this.assignedEntry.chapter.displayStack : new ItemStack(InitItems.itemBooklet), this.xPosition+2, this.yPosition+1, 0.725F);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
} }

View file

@ -12,7 +12,6 @@ package ellpeck.actuallyadditions.booklet.button;
import ellpeck.actuallyadditions.booklet.GuiBooklet; import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.booklet.chapter.BookletChapter; import ellpeck.actuallyadditions.booklet.chapter.BookletChapter;
import ellpeck.actuallyadditions.booklet.page.BookletPage;
import ellpeck.actuallyadditions.util.AssetUtil; import ellpeck.actuallyadditions.util.AssetUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
@ -43,7 +42,7 @@ public class IndexButton extends GuiButton{
if(this.chap != null){ if(this.chap != null){
if(this.chap.displayStack != null){ if(this.chap.displayStack != null){
GL11.glPushMatrix(); GL11.glPushMatrix();
BookletPage.renderItem(this.gui, this.chap.displayStack, this.xPosition-4, this.yPosition, 0.725F); AssetUtil.renderStackToGui(this.chap.displayStack, this.xPosition-4, this.yPosition, 0.725F);
GL11.glPopMatrix(); GL11.glPopMatrix();
textOffsetX = 10; textOffsetX = 10;
} }

View file

@ -21,14 +21,9 @@ import ellpeck.actuallyadditions.util.StringUtil;
import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.Util;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -46,31 +41,6 @@ public class BookletPage{
this.localizationKey = localizationKey; this.localizationKey = localizationKey;
} }
@SideOnly(Side.CLIENT)
public static void renderItem(GuiScreen gui, ItemStack stack, int x, int y, float scale){
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glTranslated(x, y, 0);
GL11.glScalef(scale, scale, scale);
Minecraft mc = Minecraft.getMinecraft();
boolean flagBefore = mc.fontRenderer.getUnicodeFlag();
mc.fontRenderer.setUnicodeFlag(false);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), stack, 0, 0);
RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.getTextureManager(), stack, 0, 0);
mc.fontRenderer.setUnicodeFlag(flagBefore);
//GL+MC+NEI suck
if(gui instanceof GuiBooklet){
RenderHelper.disableStandardItemLighting();
}
GL11.glPopMatrix();
}
public void addToPagesWithItemStackData(){ public void addToPagesWithItemStackData(){
if(!InitBooklet.pagesWithItemStackData.contains(this)){ if(!InitBooklet.pagesWithItemStackData.contains(this)){
ItemStack[] stacks = this.getItemStacksForPage(); ItemStack[] stacks = this.getItemStacksForPage();

View file

@ -15,6 +15,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.booklet.GuiBooklet; import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.proxy.ClientProxy; import ellpeck.actuallyadditions.proxy.ClientProxy;
import ellpeck.actuallyadditions.util.AssetUtil;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.StringUtil;
import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.Util;
@ -135,7 +136,7 @@ public class PageCrafting extends BookletPage{
int xShowOutput = gui.guiLeft+27+82; int xShowOutput = gui.guiLeft+27+82;
int yShowOutput = gui.guiTop+20+22; int yShowOutput = gui.guiTop+20+22;
renderItem(gui, recipe.getRecipeOutput(), xShowOutput, yShowOutput, 1.0F); AssetUtil.renderStackToGui(recipe.getRecipeOutput(), xShowOutput, yShowOutput, 1.0F);
for(int i = 0; i < 2; i++){ for(int i = 0; i < 2; i++){
boolean tooltip = i == 1; boolean tooltip = i == 1;
for(int x = 0; x < width; x++){ for(int x = 0; x < width; x++){
@ -149,7 +150,7 @@ public class PageCrafting extends BookletPage{
int xShow = gui.guiLeft+27+4+x*18; int xShow = gui.guiLeft+27+4+x*18;
int yShow = gui.guiTop+20+4+y*18; int yShow = gui.guiTop+20+4+y*18;
if(!tooltip){ if(!tooltip){
renderItem(gui, stack, xShow, yShow, 1.0F); AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
} }
else{ else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){

View file

@ -14,6 +14,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.booklet.GuiBooklet; import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.proxy.ClientProxy; import ellpeck.actuallyadditions.proxy.ClientProxy;
import ellpeck.actuallyadditions.util.AssetUtil;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.StringUtil;
import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.Util;
@ -83,7 +84,7 @@ public class PageFurnace extends BookletPage{
int xShow = gui.guiLeft+37+1+x*42; int xShow = gui.guiLeft+37+1+x*42;
int yShow = gui.guiTop+20+21; int yShow = gui.guiTop+20+21;
if(!tooltip){ if(!tooltip){
renderItem(gui, stack, xShow, yShow, 1.0F); AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
} }
else{ else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){

View file

@ -16,6 +16,7 @@ import ellpeck.actuallyadditions.blocks.InitBlocks;
import ellpeck.actuallyadditions.booklet.GuiBooklet; import ellpeck.actuallyadditions.booklet.GuiBooklet;
import ellpeck.actuallyadditions.items.lens.LensNoneRecipeHandler; import ellpeck.actuallyadditions.items.lens.LensNoneRecipeHandler;
import ellpeck.actuallyadditions.proxy.ClientProxy; import ellpeck.actuallyadditions.proxy.ClientProxy;
import ellpeck.actuallyadditions.util.AssetUtil;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.StringUtil;
import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.Util;
@ -82,7 +83,7 @@ public class PageReconstructor extends BookletPage{
} }
if(recipe != null){ if(recipe != null){
renderItem(gui, new ItemStack(InitBlocks.blockAtomicReconstructor), gui.guiLeft+37+22, gui.guiTop+20+21, 1.0F); AssetUtil.renderStackToGui(new ItemStack(InitBlocks.blockAtomicReconstructor), gui.guiLeft+37+22, gui.guiTop+20+21, 1.0F);
for(int i = 0; i < 2; i++){ for(int i = 0; i < 2; i++){
for(int x = 0; x < 2; x++){ for(int x = 0; x < 2; x++){
List<ItemStack> stacks = x == 0 ? recipe.getInputs() : recipe.getOutputs(); List<ItemStack> stacks = x == 0 ? recipe.getInputs() : recipe.getOutputs();
@ -97,7 +98,7 @@ public class PageReconstructor extends BookletPage{
int xShow = gui.guiLeft+37+1+x*42; int xShow = gui.guiLeft+37+1+x*42;
int yShow = gui.guiTop+20+21; int yShow = gui.guiTop+20+21;
if(!tooltip){ if(!tooltip){
renderItem(gui, stack, xShow, yShow, 1.0F); AssetUtil.renderStackToGui(stack, xShow, yShow, 1.0F);
} }
else{ else{
if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){ if(mouseX >= xShow && mouseX <= xShow+16 && mouseY >= yShow && mouseY <= yShow+16){

View file

@ -385,7 +385,7 @@ public class SmileyCloudEasterEggs{
GL11.glTranslatef(-0.5F, 0.2F, leftHand ? 0.55F : -0.5F); GL11.glTranslatef(-0.5F, 0.2F, leftHand ? 0.55F : -0.5F);
GL11.glScalef(0.75F, 0.75F, 0.75F); GL11.glScalef(0.75F, 0.75F, 0.75F);
AssetUtil.renderItem(stack, 0); AssetUtil.renderItemInWorld(stack, 0);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
@ -398,7 +398,7 @@ public class SmileyCloudEasterEggs{
GL11.glRotatef(180F, 1F, 0F, 0F); GL11.glRotatef(180F, 1F, 0F, 0F);
GL11.glRotatef(rotation, 0F, 1F, 0F); GL11.glRotatef(rotation, 0F, 1F, 0F);
AssetUtil.renderBlock(block, meta); AssetUtil.renderBlockInWorld(block, meta);
GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix(); GL11.glPopMatrix();

View file

@ -71,11 +71,11 @@ public class RenderSpecial{
GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHTING);
if(this.theThingToRender != null){ if(this.theThingToRender != null){
if(isBlock){ if(isBlock){
AssetUtil.renderBlock(Block.getBlockFromItem(this.theThingToRender.getItem()), this.theThingToRender.getItemDamage()); AssetUtil.renderBlockInWorld(Block.getBlockFromItem(this.theThingToRender.getItem()), this.theThingToRender.getItemDamage());
} }
else{ else{
GL11.glTranslatef(-0.5F, 0F, 0F); GL11.glTranslatef(-0.5F, 0F, 0F);
AssetUtil.renderItem(this.theThingToRender, 0); AssetUtil.renderItemInWorld(this.theThingToRender, 0);
} }
} }
GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHTING);

View file

@ -12,18 +12,18 @@ package ellpeck.actuallyadditions.util;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.booklet.GuiBooklet;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class AssetUtil{ public class AssetUtil{
@ -52,7 +52,7 @@ public class AssetUtil{
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void renderItem(ItemStack stack, int renderPass){ public static void renderItemInWorld(ItemStack stack, int renderPass){
IIcon icon = stack.getItem().getIcon(stack, renderPass); IIcon icon = stack.getItem().getIcon(stack, renderPass);
float f = icon.getMinU(); float f = icon.getMinU();
float f1 = icon.getMaxU(); float f1 = icon.getMaxU();
@ -63,11 +63,36 @@ public class AssetUtil{
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void renderBlock(Block block, int meta){ public static void renderBlockInWorld(Block block, int meta){
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
RenderBlocks.getInstance().renderBlockAsItem(block, meta, 1F); RenderBlocks.getInstance().renderBlockAsItem(block, meta, 1F);
} }
@SideOnly(Side.CLIENT)
public static void renderStackToGui(ItemStack stack, int x, int y, float scale){
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glTranslated(x, y, 0);
GL11.glScalef(scale, scale, scale);
Minecraft mc = Minecraft.getMinecraft();
boolean flagBefore = mc.fontRenderer.getUnicodeFlag();
mc.fontRenderer.setUnicodeFlag(false);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), stack, 0, 0);
RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.getTextureManager(), stack, 0, 0);
mc.fontRenderer.setUnicodeFlag(flagBefore);
//GL+MC+NEI suck
if(mc.currentScreen instanceof GuiBooklet){
RenderHelper.disableStandardItemLighting();
}
GL11.glPopMatrix();
}
//Copied from Gui.class and changed //Copied from Gui.class and changed
public static void drawHorizontalGradientRect(int startX, int startY, int endX, int endY, int firstColor, int secondColor){ public static void drawHorizontalGradientRect(int startX, int startY, int endX, int endY, int firstColor, int secondColor){
float f = (float)(firstColor >> 24 & 255)/255.0F; float f = (float)(firstColor >> 24 & 255)/255.0F;

View file

@ -10,8 +10,11 @@
package ellpeck.actuallyadditions.util; package ellpeck.actuallyadditions.util;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import java.util.Iterator;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Objects; import java.util.Objects;
@ -48,4 +51,12 @@ public class StringUtil{
return string.toLowerCase(Locale.ROOT); return string.toLowerCase(Locale.ROOT);
} }
} }
public static void drawSplitStringWithShadow(FontRenderer renderer, String strg, int x, int y, int width, int color){
List list = renderer.listFormattedStringToWidth(strg, width);
for(Iterator iterator = list.iterator(); iterator.hasNext(); y += renderer.FONT_HEIGHT){
String s1 = (String)iterator.next();
renderer.drawString(s1, x, y, color, true);
}
}
} }