2015-08-29 14:33:25 +02:00
|
|
|
/*
|
|
|
|
* This file ("AssetUtil.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-01-03 16:05:51 +01:00
|
|
|
* http://ellpeck.de/actaddlicense/
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-01-03 16:05:51 +01:00
|
|
|
* © 2016 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.util;
|
2015-03-29 15:29:05 +02:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
|
2015-08-24 17:57:11 +02:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.client.Minecraft;
|
2015-04-19 01:50:02 +02:00
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
2016-01-07 21:41:28 +01:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2016-01-07 18:20:59 +01:00
|
|
|
import net.minecraft.client.renderer.RenderHelper;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
2016-01-07 21:41:28 +01:00
|
|
|
import net.minecraft.client.renderer.WorldRenderer;
|
|
|
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
2015-08-24 17:57:11 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-03-29 15:29:05 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2016-01-07 18:20:59 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-10-23 19:05:02 +02:00
|
|
|
import org.lwjgl.opengl.GL11;
|
2015-12-22 14:55:10 +01:00
|
|
|
import org.lwjgl.opengl.GL12;
|
2015-03-29 15:29:05 +02:00
|
|
|
|
|
|
|
public class AssetUtil{
|
|
|
|
|
2015-10-03 10:16:18 +02:00
|
|
|
public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("guiInventory");
|
2016-01-07 19:04:29 +01:00
|
|
|
public static final int TESR_RENDER_ID = 2;
|
2015-11-13 18:56:15 +01:00
|
|
|
|
2016-01-07 23:42:42 +01:00
|
|
|
public static int compostRenderId;
|
2015-11-13 18:56:15 +01:00
|
|
|
public static int fishingNetRenderId;
|
|
|
|
public static int furnaceSolarRenderId;
|
|
|
|
public static int coffeeMachineRenderId;
|
|
|
|
public static int phantomBoosterRenderId;
|
|
|
|
public static int smileyCloudRenderId;
|
|
|
|
public static int laserRelayRenderId;
|
2016-01-07 23:42:42 +01:00
|
|
|
public static int bookletStandRenderId;
|
2015-08-26 19:33:35 +02:00
|
|
|
|
2015-03-29 15:29:05 +02:00
|
|
|
public static ResourceLocation getGuiLocation(String file){
|
2015-10-02 16:48:01 +02:00
|
|
|
return new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/gui/"+file+".png");
|
2015-03-29 15:29:05 +02:00
|
|
|
}
|
|
|
|
|
2015-10-30 20:07:36 +01:00
|
|
|
public static ResourceLocation getBookletGuiLocation(String file){
|
|
|
|
return new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/gui/booklet/"+file+".png");
|
|
|
|
}
|
|
|
|
|
2015-05-20 22:39:43 +02:00
|
|
|
public static void displayNameString(FontRenderer font, int xSize, int yPositionOfMachineText, String machineName){
|
2015-08-01 00:40:29 +02:00
|
|
|
String localMachineName = StringUtil.localize(machineName+".name");
|
2015-10-02 16:48:01 +02:00
|
|
|
font.drawString(localMachineName, xSize/2-font.getStringWidth(localMachineName)/2, yPositionOfMachineText, StringUtil.DECIMAL_COLOR_WHITE);
|
2015-04-19 01:50:02 +02:00
|
|
|
}
|
2015-08-24 17:57:11 +02:00
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2015-12-22 14:55:10 +01:00
|
|
|
public static void renderItemInWorld(ItemStack stack, int renderPass){
|
2016-01-07 21:41:28 +01:00
|
|
|
//TODO Fix rendering items in world
|
|
|
|
/*IIcon icon = stack.getItem().getIcon(stack, renderPass);
|
2015-08-24 17:57:11 +02:00
|
|
|
float f = icon.getMinU();
|
|
|
|
float f1 = icon.getMaxU();
|
|
|
|
float f2 = icon.getMinV();
|
|
|
|
float f3 = icon.getMaxV();
|
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
2016-01-07 21:41:28 +01:00
|
|
|
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F/16F);*/
|
2015-08-24 17:57:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2015-12-22 14:55:10 +01:00
|
|
|
public static void renderBlockInWorld(Block block, int meta){
|
2016-01-07 21:41:28 +01:00
|
|
|
//TODO Fix rendering blocks in world
|
|
|
|
/*Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
|
|
|
RenderBlocks.getInstance().renderBlockAsItem(block, meta, 1F);*/
|
2015-08-24 17:57:11 +02:00
|
|
|
}
|
2015-10-23 19:05:02 +02:00
|
|
|
|
2015-12-22 14:55:10 +01:00
|
|
|
@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();
|
2016-01-07 21:41:28 +01:00
|
|
|
boolean flagBefore = mc.fontRendererObj.getUnicodeFlag();
|
|
|
|
mc.fontRendererObj.setUnicodeFlag(false);
|
|
|
|
Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, 0, 0);
|
|
|
|
Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(mc.fontRendererObj, stack, 0, 0, null);
|
|
|
|
mc.fontRendererObj.setUnicodeFlag(flagBefore);
|
2015-12-22 14:55:10 +01:00
|
|
|
|
|
|
|
//GL+MC+NEI suck
|
2015-12-22 15:01:40 +01:00
|
|
|
if(mc.currentScreen instanceof GuiBooklet || mc.currentScreen == null){
|
2015-12-22 14:55:10 +01:00
|
|
|
RenderHelper.disableStandardItemLighting();
|
|
|
|
}
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
|
2015-10-23 19:05:02 +02:00
|
|
|
//Copied from Gui.class and changed
|
2016-01-07 21:41:28 +01:00
|
|
|
public static void drawHorizontalGradientRect(int left, int top, int right, int bottom, int startColor, int endColor, float zLevel){
|
|
|
|
float f = (float)(startColor >> 24 & 255)/255.0F;
|
|
|
|
float f1 = (float)(startColor >> 16 & 255)/255.0F;
|
|
|
|
float f2 = (float)(startColor >> 8 & 255)/255.0F;
|
|
|
|
float f3 = (float)(startColor & 255)/255.0F;
|
|
|
|
float f4 = (float)(endColor >> 24 & 255)/255.0F;
|
|
|
|
float f5 = (float)(endColor >> 16 & 255)/255.0F;
|
|
|
|
float f6 = (float)(endColor >> 8 & 255)/255.0F;
|
|
|
|
float f7 = (float)(endColor & 255)/255.0F;
|
|
|
|
GlStateManager.disableTexture2D();
|
|
|
|
GlStateManager.enableBlend();
|
|
|
|
GlStateManager.disableAlpha();
|
|
|
|
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
|
|
|
GlStateManager.shadeModel(7425);
|
|
|
|
Tessellator tessellator = Tessellator.getInstance();
|
|
|
|
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
|
|
|
worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
|
|
|
worldrenderer.pos((double)right, (double)top, (double)zLevel).color(f1, f2, f3, f).endVertex();
|
|
|
|
worldrenderer.pos((double)left, (double)top, (double)zLevel).color(f1, f2, f3, f).endVertex();
|
|
|
|
worldrenderer.pos((double)left, (double)bottom, (double)zLevel).color(f5, f6, f7, f4).endVertex();
|
|
|
|
worldrenderer.pos((double)right, (double)bottom, (double)zLevel).color(f5, f6, f7, f4).endVertex();
|
2015-10-23 19:05:02 +02:00
|
|
|
tessellator.draw();
|
2016-01-07 21:41:28 +01:00
|
|
|
GlStateManager.shadeModel(7424);
|
|
|
|
GlStateManager.disableBlend();
|
|
|
|
GlStateManager.enableAlpha();
|
|
|
|
GlStateManager.enableTexture2D();
|
2015-10-23 19:05:02 +02:00
|
|
|
}
|
2015-03-29 15:29:05 +02:00
|
|
|
}
|