2012-08-06 10:35:57 +00:00
|
|
|
package net.minecraftforge.client;
|
|
|
|
|
2012-08-07 08:24:06 +00:00
|
|
|
import java.util.Random;
|
2014-02-21 17:13:40 +00:00
|
|
|
|
2013-06-08 19:20:49 +00:00
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
2013-09-04 21:00:04 +00:00
|
|
|
import net.minecraftforge.client.event.MouseEvent;
|
2014-04-03 10:12:22 +00:00
|
|
|
import net.minecraft.client.audio.ISound;
|
|
|
|
import net.minecraft.client.audio.SoundEventAccessorComposite;
|
|
|
|
import net.minecraft.client.audio.SoundManager;
|
2013-09-06 00:14:24 +00:00
|
|
|
import net.minecraft.client.entity.EntityPlayerSP;
|
2013-12-25 08:35:59 +00:00
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
|
|
|
import net.minecraft.client.gui.GuiMainMenu;
|
2013-09-06 00:14:24 +00:00
|
|
|
import net.minecraftforge.client.event.FOVUpdateEvent;
|
2013-12-10 05:59:12 +00:00
|
|
|
|
2013-05-09 00:13:19 +00:00
|
|
|
import org.lwjgl.LWJGLException;
|
|
|
|
import org.lwjgl.opengl.Display;
|
2012-08-06 10:35:57 +00:00
|
|
|
import org.lwjgl.opengl.GL11;
|
2012-08-07 08:24:06 +00:00
|
|
|
import org.lwjgl.opengl.GL12;
|
2013-05-09 00:13:19 +00:00
|
|
|
import org.lwjgl.opengl.PixelFormat;
|
2012-08-06 10:35:57 +00:00
|
|
|
|
2012-09-09 14:02:21 +00:00
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
2014-01-30 05:04:34 +00:00
|
|
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
2013-12-21 08:10:35 +00:00
|
|
|
import cpw.mods.fml.common.FMLLog;
|
2012-08-07 08:24:06 +00:00
|
|
|
import net.minecraft.client.Minecraft;
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.block.Block;
|
2014-01-30 05:04:34 +00:00
|
|
|
import net.minecraft.block.BlockLiquid;
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.entity.item.EntityItem;
|
2013-04-05 00:28:50 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
2013-06-30 12:50:11 +00:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-12-21 08:10:35 +00:00
|
|
|
import net.minecraft.item.ItemBlock;
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2013-12-21 08:10:35 +00:00
|
|
|
import net.minecraft.util.ChatComponentTranslation;
|
2013-12-25 08:35:59 +00:00
|
|
|
import net.minecraft.util.EnumChatFormatting;
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
2014-05-20 17:51:46 +00:00
|
|
|
import net.minecraft.world.ChunkCache;
|
2013-09-14 03:11:59 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraft.world.biome.BiomeGenBase;
|
2013-04-05 02:10:07 +00:00
|
|
|
import net.minecraft.client.model.ModelBiped;
|
2013-12-21 08:10:35 +00:00
|
|
|
import net.minecraft.client.renderer.OpenGlHelper;
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.client.renderer.RenderGlobal;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
2014-05-20 17:51:46 +00:00
|
|
|
import net.minecraft.client.renderer.WorldRenderer;
|
2013-02-15 12:10:49 +00:00
|
|
|
import net.minecraft.client.renderer.entity.RenderItem;
|
2013-06-30 12:50:11 +00:00
|
|
|
import net.minecraft.client.renderer.texture.TextureManager;
|
2013-03-18 03:07:30 +00:00
|
|
|
import net.minecraft.client.renderer.texture.TextureMap;
|
2014-06-02 22:28:11 +00:00
|
|
|
import net.minecraft.client.resources.I18n;
|
2013-12-21 08:10:35 +00:00
|
|
|
import net.minecraft.client.settings.GameSettings;
|
2013-05-04 20:59:47 +00:00
|
|
|
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
2012-08-23 01:02:14 +00:00
|
|
|
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
2014-02-21 17:13:40 +00:00
|
|
|
import net.minecraftforge.client.event.RenderHandEvent;
|
2014-05-20 17:51:46 +00:00
|
|
|
import net.minecraftforge.client.event.RenderWorldEvent;
|
2012-08-23 01:02:14 +00:00
|
|
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
2013-03-18 03:07:30 +00:00
|
|
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
2014-04-03 10:12:22 +00:00
|
|
|
import net.minecraftforge.client.event.sound.PlaySoundEvent17;
|
2013-12-13 07:32:36 +00:00
|
|
|
import net.minecraftforge.common.ForgeModContainer;
|
2013-12-25 08:35:59 +00:00
|
|
|
import net.minecraftforge.common.ForgeVersion;
|
|
|
|
import net.minecraftforge.common.ForgeVersion.Status;
|
2012-08-07 08:24:06 +00:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2014-01-30 05:04:34 +00:00
|
|
|
import net.minecraftforge.fluids.FluidRegistry;
|
|
|
|
import net.minecraftforge.fluids.RenderBlockFluid;
|
2012-08-07 08:24:06 +00:00
|
|
|
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*;
|
|
|
|
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.*;
|
2013-12-25 08:35:59 +00:00
|
|
|
import static net.minecraftforge.common.ForgeVersion.Status.*;
|
2012-08-06 10:35:57 +00:00
|
|
|
|
|
|
|
public class ForgeHooksClient
|
|
|
|
{
|
2014-01-18 05:55:48 +00:00
|
|
|
//private static final ResourceLocation ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
|
2014-06-30 01:42:48 +00:00
|
|
|
|
2013-06-30 12:50:11 +00:00
|
|
|
static TextureManager engine()
|
2012-09-09 14:02:21 +00:00
|
|
|
{
|
|
|
|
return FMLClientHandler.instance().getClient().renderEngine;
|
|
|
|
}
|
2012-08-06 10:35:57 +00:00
|
|
|
|
2013-07-24 20:12:38 +00:00
|
|
|
public static String getArmorTexture(Entity entity, ItemStack armor, String _default, int slot, String type)
|
|
|
|
{
|
|
|
|
String result = armor.getItem().getArmorTexture(armor, entity, slot, type);
|
2013-04-05 00:28:50 +00:00
|
|
|
return result != null ? result : _default;
|
2012-08-07 00:52:23 +00:00
|
|
|
}
|
2012-08-07 08:24:06 +00:00
|
|
|
|
2013-12-21 08:10:35 +00:00
|
|
|
public static boolean renderEntityItem(EntityItem entity, ItemStack item, float bobing, float rotation, Random random, TextureManager engine, RenderBlocks renderBlocks, int count)
|
2012-08-07 08:24:06 +00:00
|
|
|
{
|
|
|
|
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(item, ENTITY);
|
|
|
|
if (customRenderer == null)
|
|
|
|
{
|
2012-12-18 14:56:28 +00:00
|
|
|
return false;
|
2012-08-07 08:24:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (customRenderer.shouldUseRenderHelper(ENTITY, item, ENTITY_ROTATION))
|
|
|
|
{
|
|
|
|
GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
|
|
|
|
}
|
|
|
|
if (!customRenderer.shouldUseRenderHelper(ENTITY, item, ENTITY_BOBBING))
|
|
|
|
{
|
|
|
|
GL11.glTranslatef(0.0F, -bobing, 0.0F);
|
|
|
|
}
|
|
|
|
boolean is3D = customRenderer.shouldUseRenderHelper(ENTITY, item, BLOCK_3D);
|
2012-08-23 01:02:14 +00:00
|
|
|
|
2013-09-03 19:52:58 +00:00
|
|
|
engine.bindTexture(item.getItemSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
|
2014-02-05 08:05:37 +00:00
|
|
|
Block block = item.getItem() instanceof ItemBlock ? Block.getBlockFromItem(item.getItem()) : null;
|
|
|
|
if (is3D || (block != null && RenderBlocks.renderItemIn3d(block.getRenderType())))
|
2012-08-07 08:24:06 +00:00
|
|
|
{
|
2014-02-05 08:05:37 +00:00
|
|
|
int renderType = (block != null ? block.getRenderType() : 1);
|
2012-08-07 08:24:06 +00:00
|
|
|
float scale = (renderType == 1 || renderType == 19 || renderType == 12 || renderType == 2 ? 0.5F : 0.25F);
|
2014-02-05 08:05:37 +00:00
|
|
|
boolean blend = block != null && block.getRenderBlockPass() > 0;
|
2012-08-07 08:24:06 +00:00
|
|
|
|
2013-03-20 01:09:34 +00:00
|
|
|
if (RenderItem.renderInFrame)
|
2013-02-15 12:10:49 +00:00
|
|
|
{
|
|
|
|
GL11.glScalef(1.25F, 1.25F, 1.25F);
|
|
|
|
GL11.glTranslatef(0.0F, 0.05F, 0.0F);
|
|
|
|
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
|
|
|
}
|
|
|
|
|
2013-12-21 08:10:35 +00:00
|
|
|
if (blend)
|
|
|
|
{
|
|
|
|
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
|
|
|
|
GL11.glEnable(GL11.GL_BLEND);
|
2014-02-05 08:05:37 +00:00
|
|
|
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
2013-12-21 08:10:35 +00:00
|
|
|
}
|
2013-07-08 21:30:25 +00:00
|
|
|
|
2013-12-21 08:10:35 +00:00
|
|
|
GL11.glScalef(scale, scale, scale);
|
2012-09-09 14:02:21 +00:00
|
|
|
|
2012-09-17 07:25:26 +00:00
|
|
|
for(int j = 0; j < count; j++)
|
2012-08-07 08:24:06 +00:00
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
if (j > 0)
|
|
|
|
{
|
|
|
|
GL11.glTranslatef(
|
2013-05-19 20:22:12 +00:00
|
|
|
((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / scale,
|
|
|
|
((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / scale,
|
|
|
|
((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / scale);
|
2012-08-07 08:24:06 +00:00
|
|
|
}
|
|
|
|
customRenderer.renderItem(ENTITY, item, renderBlocks, entity);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
2013-12-21 08:10:35 +00:00
|
|
|
|
|
|
|
if (blend)
|
|
|
|
{
|
|
|
|
GL11.glDisable(GL11.GL_BLEND);
|
|
|
|
}
|
2012-08-07 08:24:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
|
|
|
customRenderer.renderItem(ENTITY, item, renderBlocks, entity);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-09-09 14:02:21 +00:00
|
|
|
|
2013-06-30 12:50:11 +00:00
|
|
|
public static boolean renderInventoryItem(RenderBlocks renderBlocks, TextureManager engine, ItemStack item, boolean inColor, float zLevel, float x, float y)
|
2012-08-07 08:24:06 +00:00
|
|
|
{
|
|
|
|
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(item, INVENTORY);
|
|
|
|
if (customRenderer == null)
|
|
|
|
{
|
2013-03-19 20:49:31 +00:00
|
|
|
return false;
|
2012-08-07 08:24:06 +00:00
|
|
|
}
|
|
|
|
|
2013-09-03 19:52:58 +00:00
|
|
|
engine.bindTexture(item.getItemSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
|
2012-08-07 08:24:06 +00:00
|
|
|
if (customRenderer.shouldUseRenderHelper(INVENTORY, item, INVENTORY_BLOCK))
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glTranslatef(x - 2, y + 3, -3.0F + zLevel);
|
|
|
|
GL11.glScalef(10F, 10F, 10F);
|
|
|
|
GL11.glTranslatef(1.0F, 0.5F, 1.0F);
|
|
|
|
GL11.glScalef(1.0F, 1.0F, -1F);
|
|
|
|
GL11.glRotatef(210F, 1.0F, 0.0F, 0.0F);
|
|
|
|
GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F);
|
2012-08-23 01:02:14 +00:00
|
|
|
|
2012-08-07 08:24:06 +00:00
|
|
|
if(inColor)
|
|
|
|
{
|
2013-12-21 08:10:35 +00:00
|
|
|
int color = item.getItem().getColorFromItemStack(item, 0);
|
2012-08-07 08:24:06 +00:00
|
|
|
float r = (float)(color >> 16 & 0xff) / 255F;
|
|
|
|
float g = (float)(color >> 8 & 0xff) / 255F;
|
|
|
|
float b = (float)(color & 0xff) / 255F;
|
|
|
|
GL11.glColor4f(r, g, b, 1.0F);
|
|
|
|
}
|
2012-08-23 01:02:14 +00:00
|
|
|
|
2012-08-07 08:24:06 +00:00
|
|
|
GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F);
|
2014-02-05 08:05:37 +00:00
|
|
|
renderBlocks.useInventoryTint = inColor;
|
2012-08-07 08:24:06 +00:00
|
|
|
customRenderer.renderItem(INVENTORY, item, renderBlocks);
|
2014-02-05 08:05:37 +00:00
|
|
|
renderBlocks.useInventoryTint = true;
|
2012-08-07 08:24:06 +00:00
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glTranslatef(x, y, -3.0F + zLevel);
|
|
|
|
|
|
|
|
if (inColor)
|
|
|
|
{
|
2013-12-21 08:10:35 +00:00
|
|
|
int color = item.getItem().getColorFromItemStack(item, 0);
|
2012-08-07 08:24:06 +00:00
|
|
|
float r = (float)(color >> 16 & 255) / 255.0F;
|
|
|
|
float g = (float)(color >> 8 & 255) / 255.0F;
|
|
|
|
float b = (float)(color & 255) / 255.0F;
|
|
|
|
GL11.glColor4f(r, g, b, 1.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
customRenderer.renderItem(INVENTORY, item, renderBlocks);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
|
|
}
|
2013-07-08 21:30:25 +00:00
|
|
|
|
2012-08-07 08:24:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-05-04 20:59:47 +00:00
|
|
|
|
2013-07-04 04:14:59 +00:00
|
|
|
public static void renderEffectOverlay(TextureManager manager, RenderItem render)
|
2012-08-07 08:24:06 +00:00
|
|
|
{
|
2013-05-04 20:59:47 +00:00
|
|
|
}
|
|
|
|
|
2013-06-30 12:50:11 +00:00
|
|
|
public static void renderEquippedItem(ItemRenderType type, IItemRenderer customRenderer, RenderBlocks renderBlocks, EntityLivingBase entity, ItemStack item)
|
2013-05-04 20:59:47 +00:00
|
|
|
{
|
|
|
|
if (customRenderer.shouldUseRenderHelper(type, item, EQUIPPED_BLOCK))
|
2012-08-07 08:24:06 +00:00
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
2013-05-04 20:59:47 +00:00
|
|
|
customRenderer.renderItem(type, item, renderBlocks, entity);
|
2012-08-07 08:24:06 +00:00
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
|
|
GL11.glTranslatef(0.0F, -0.3F, 0.0F);
|
|
|
|
GL11.glScalef(1.5F, 1.5F, 1.5F);
|
|
|
|
GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
|
|
|
|
GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
|
|
|
|
GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
|
2013-05-04 20:59:47 +00:00
|
|
|
customRenderer.renderItem(type, item, renderBlocks, entity);
|
2012-08-07 08:24:06 +00:00
|
|
|
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
}
|
2012-08-23 01:02:14 +00:00
|
|
|
|
|
|
|
//Optifine Helper Functions u.u, these are here specifically for Optifine
|
|
|
|
//Note: When using Optfine, these methods are invoked using reflection, which
|
|
|
|
//incurs a major performance penalty.
|
2013-06-30 12:50:11 +00:00
|
|
|
public static void orientBedCamera(Minecraft mc, EntityLivingBase entity)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
|
|
|
int x = MathHelper.floor_double(entity.posX);
|
|
|
|
int y = MathHelper.floor_double(entity.posY);
|
|
|
|
int z = MathHelper.floor_double(entity.posZ);
|
2014-02-05 08:05:37 +00:00
|
|
|
Block block = mc.theWorld.getBlock(x, y, z);
|
2012-08-23 01:02:14 +00:00
|
|
|
|
|
|
|
if (block != null && block.isBed(mc.theWorld, x, y, z, entity))
|
|
|
|
{
|
2013-12-21 08:10:35 +00:00
|
|
|
GL11.glRotatef((float)(block.getBedDirection(mc.theWorld, x, y, z) * 90), 0.0F, 1.0F, 0.0F);
|
2012-08-23 01:02:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onDrawBlockHighlight(RenderGlobal context, EntityPlayer player, MovingObjectPosition target, int subID, ItemStack currentItem, float partialTicks)
|
|
|
|
{
|
|
|
|
return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent(context, player, target, subID, currentItem, partialTicks));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void dispatchRenderLast(RenderGlobal context, float partialTicks)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new RenderWorldLastEvent(context, partialTicks));
|
|
|
|
}
|
|
|
|
|
2014-02-21 17:13:40 +00:00
|
|
|
public static boolean renderFirstPersonHand(RenderGlobal context, float partialTicks, int renderPass)
|
|
|
|
{
|
|
|
|
return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(context, partialTicks, renderPass));
|
|
|
|
}
|
|
|
|
|
2013-03-18 03:07:30 +00:00
|
|
|
public static void onTextureStitchedPre(TextureMap map)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Pre(map));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void onTextureStitchedPost(TextureMap map)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Post(map));
|
2013-07-08 21:30:25 +00:00
|
|
|
|
2014-02-05 08:05:37 +00:00
|
|
|
FluidRegistry.WATER.setIcons(BlockLiquid.getLiquidIcon("water_still"), BlockLiquid.getLiquidIcon("water_flow"));
|
|
|
|
FluidRegistry.LAVA.setIcons(BlockLiquid.getLiquidIcon("lava_still"), BlockLiquid.getLiquidIcon("lava_flow"));
|
2013-03-18 03:07:30 +00:00
|
|
|
}
|
|
|
|
|
2012-08-23 01:02:14 +00:00
|
|
|
/**
|
|
|
|
* This is added for Optifine's convenience. And to explode if a ModMaker is developing.
|
|
|
|
* @param texture
|
|
|
|
*/
|
|
|
|
public static void onTextureLoadPre(String texture)
|
|
|
|
{
|
|
|
|
if (Tessellator.renderingWorldRenderer)
|
|
|
|
{
|
2013-12-21 08:10:35 +00:00
|
|
|
FMLLog.warning("Warning: Texture %s not preloaded, will cause render glitches!", texture);
|
2012-08-23 01:02:14 +00:00
|
|
|
if (Tessellator.class.getPackage() != null)
|
|
|
|
{
|
2013-01-02 04:57:45 +00:00
|
|
|
if (Tessellator.class.getPackage().getName().startsWith("net.minecraft."))
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
2012-09-09 14:02:21 +00:00
|
|
|
Minecraft mc = FMLClientHandler.instance().getClient();
|
2012-08-23 01:02:14 +00:00
|
|
|
if (mc.ingameGUI != null)
|
|
|
|
{
|
2014-02-05 08:05:37 +00:00
|
|
|
mc.ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("forge.texture.preload.warning", texture));
|
2012-08-23 01:02:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-07 03:18:26 +00:00
|
|
|
|
|
|
|
static int renderPass = -1;
|
|
|
|
public static void setRenderPass(int pass)
|
|
|
|
{
|
|
|
|
renderPass = pass;
|
|
|
|
}
|
2013-04-05 02:10:07 +00:00
|
|
|
|
2013-06-30 12:50:11 +00:00
|
|
|
public static ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int slotID, ModelBiped _default)
|
2013-04-05 02:10:07 +00:00
|
|
|
{
|
|
|
|
ModelBiped modelbiped = itemStack.getItem().getArmorModel(entityLiving, itemStack, slotID);
|
|
|
|
return modelbiped == null ? _default : modelbiped;
|
|
|
|
}
|
2013-05-09 00:13:19 +00:00
|
|
|
|
|
|
|
static int stencilBits = 0;
|
|
|
|
public static void createDisplay() throws LWJGLException
|
|
|
|
{
|
2013-06-08 19:20:49 +00:00
|
|
|
ImageIO.setUseCache(false); //Disable on-disc stream cache should speed up texture pack reloading.
|
2013-05-09 00:13:19 +00:00
|
|
|
PixelFormat format = new PixelFormat().withDepthBits(24);
|
2014-10-06 22:12:12 +00:00
|
|
|
if (!Boolean.parseBoolean(System.getProperty("forge.forceDisplayStencil", "false")))
|
2014-06-30 01:42:48 +00:00
|
|
|
{
|
2014-10-06 22:12:12 +00:00
|
|
|
//Creating the display with Stencil bits causes issues on some displays.
|
|
|
|
//According to ChickenBones, Mumfrey and Pig The only real use is in the FBO.
|
|
|
|
//So lets default to normal init to fix the issues yet add the bits to the FBO.
|
2014-06-30 01:42:48 +00:00
|
|
|
Display.create(format);
|
2014-10-13 05:11:40 +00:00
|
|
|
stencilBits = 0;
|
2014-06-30 01:42:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-09 00:13:19 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
//TODO: Figure out how to determine the max bits.
|
|
|
|
Display.create(format.withStencilBits(8));
|
|
|
|
stencilBits = 8;
|
|
|
|
}
|
|
|
|
catch(LWJGLException e)
|
|
|
|
{
|
|
|
|
Display.create(format);
|
|
|
|
stencilBits = 0;
|
|
|
|
}
|
|
|
|
}
|
2013-05-23 05:01:19 +00:00
|
|
|
|
2013-07-04 02:31:54 +00:00
|
|
|
//This properly moves the domain, if provided, to the front of the string before concatenating
|
|
|
|
public static String fixDomain(String base, String complex)
|
|
|
|
{
|
|
|
|
int idx = complex.indexOf(':');
|
|
|
|
if (idx == -1)
|
|
|
|
{
|
|
|
|
return base + complex;
|
|
|
|
}
|
|
|
|
|
|
|
|
String name = complex.substring(idx + 1, complex.length());
|
|
|
|
if (idx > 1)
|
|
|
|
{
|
|
|
|
String domain = complex.substring(0, idx);
|
|
|
|
return domain + ':' + base + name;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return base + name;
|
|
|
|
}
|
|
|
|
}
|
2013-06-06 13:39:19 +00:00
|
|
|
|
2013-09-06 00:14:24 +00:00
|
|
|
public static boolean postMouseEvent()
|
|
|
|
{
|
2013-09-04 21:00:04 +00:00
|
|
|
return MinecraftForge.EVENT_BUS.post(new MouseEvent());
|
|
|
|
}
|
|
|
|
|
2013-09-06 00:14:24 +00:00
|
|
|
public static float getOffsetFOV(EntityPlayerSP entity, float fov)
|
|
|
|
{
|
|
|
|
FOVUpdateEvent fovUpdateEvent = new FOVUpdateEvent(entity, fov);
|
|
|
|
MinecraftForge.EVENT_BUS.post(fovUpdateEvent);
|
|
|
|
return fovUpdateEvent.newfov;
|
|
|
|
}
|
|
|
|
|
2013-09-14 03:11:59 +00:00
|
|
|
private static int skyX, skyZ;
|
|
|
|
|
|
|
|
private static boolean skyInit;
|
|
|
|
private static int skyRGBMultiplier;
|
2014-06-30 01:42:48 +00:00
|
|
|
|
2013-12-10 05:59:12 +00:00
|
|
|
public static int getSkyBlendColour(World world, int playerX, int playerY, int playerZ)
|
2013-09-14 03:11:59 +00:00
|
|
|
{
|
|
|
|
if (playerX == skyX && playerZ == skyZ && skyInit)
|
|
|
|
{
|
|
|
|
return skyRGBMultiplier;
|
|
|
|
}
|
|
|
|
skyInit = true;
|
2013-12-21 08:10:35 +00:00
|
|
|
|
|
|
|
GameSettings settings = Minecraft.getMinecraft().gameSettings;
|
|
|
|
int[] ranges = ForgeModContainer.blendRanges;
|
|
|
|
int distance = 0;
|
2014-02-05 08:05:37 +00:00
|
|
|
if (settings.fancyGraphics && settings.renderDistanceChunks >= 0 && settings.renderDistanceChunks < ranges.length)
|
2013-12-21 08:10:35 +00:00
|
|
|
{
|
2014-02-05 08:05:37 +00:00
|
|
|
distance = ranges[settings.renderDistanceChunks];
|
2013-12-21 08:10:35 +00:00
|
|
|
}
|
2014-06-30 01:42:48 +00:00
|
|
|
|
2013-09-14 03:11:59 +00:00
|
|
|
int r = 0;
|
|
|
|
int g = 0;
|
|
|
|
int b = 0;
|
|
|
|
|
2013-09-14 03:57:29 +00:00
|
|
|
int divider = 0;
|
2013-09-14 03:11:59 +00:00
|
|
|
for (int x = -distance; x <= distance; ++x)
|
|
|
|
{
|
|
|
|
for (int z = -distance; z <= distance; ++z)
|
|
|
|
{
|
|
|
|
BiomeGenBase biome = world.getBiomeGenForCoords(playerX + x, playerZ + z);
|
2014-02-05 08:05:37 +00:00
|
|
|
int colour = biome.getSkyColorByTemp(biome.getFloatTemperature(playerX + x, playerY, playerZ + z));
|
2013-09-14 03:11:59 +00:00
|
|
|
r += (colour & 0xFF0000) >> 16;
|
|
|
|
g += (colour & 0x00FF00) >> 8;
|
|
|
|
b += colour & 0x0000FF;
|
2013-09-14 03:57:29 +00:00
|
|
|
divider++;
|
2013-09-14 03:11:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-14 03:57:29 +00:00
|
|
|
int multiplier = (r / divider & 255) << 16 | (g / divider & 255) << 8 | b / divider & 255;
|
2013-09-14 03:11:59 +00:00
|
|
|
|
|
|
|
skyX = playerX;
|
|
|
|
skyZ = playerZ;
|
|
|
|
skyRGBMultiplier = multiplier;
|
|
|
|
return skyRGBMultiplier;
|
|
|
|
}
|
2013-05-23 05:01:19 +00:00
|
|
|
/**
|
|
|
|
* Initialization of Forge Renderers.
|
|
|
|
*/
|
2013-09-06 00:14:24 +00:00
|
|
|
static
|
|
|
|
{
|
2014-01-30 05:04:34 +00:00
|
|
|
FluidRegistry.renderIdFluid = RenderingRegistry.getNextAvailableRenderId();
|
|
|
|
RenderingRegistry.registerBlockHandler(RenderBlockFluid.instance);
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
2013-12-25 08:35:59 +00:00
|
|
|
|
|
|
|
public static void renderMainMenu(GuiMainMenu gui, FontRenderer font, int width, int height)
|
|
|
|
{
|
|
|
|
Status status = ForgeVersion.getStatus();
|
|
|
|
if (status == BETA || status == BETA_OUTDATED)
|
|
|
|
{
|
|
|
|
// render a warning at the top of the screen,
|
2014-06-02 22:28:11 +00:00
|
|
|
String line = I18n.format("forge.update.beta.1", EnumChatFormatting.RED, EnumChatFormatting.RESET);
|
2013-12-25 08:35:59 +00:00
|
|
|
gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (0 * (font.FONT_HEIGHT + 1)), -1);
|
2014-06-02 22:28:11 +00:00
|
|
|
line = I18n.format("forge.update.beta.2");
|
2013-12-25 08:35:59 +00:00
|
|
|
gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (1 * (font.FONT_HEIGHT + 1)), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
String line = null;
|
|
|
|
switch(status)
|
|
|
|
{
|
|
|
|
//case FAILED: line = " Version check failed"; break;
|
|
|
|
//case UP_TO_DATE: line = "Forge up to date"}; break;
|
|
|
|
//case AHEAD: line = "Using non-recommended Forge build, issues may arise."}; break;
|
|
|
|
case OUTDATED:
|
2014-06-02 22:28:11 +00:00
|
|
|
case BETA_OUTDATED: line = I18n.format("forge.update.newversion", ForgeVersion.getTarget()); break;
|
2013-12-25 08:35:59 +00:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (line != null)
|
|
|
|
{
|
|
|
|
// if we have a line, render it in the bottom right, above Mojang's copyright line
|
|
|
|
gui.drawString(font, line, width - font.getStringWidth(line) - 2, height - (2 * (font.FONT_HEIGHT + 1)), -1);
|
|
|
|
}
|
|
|
|
}
|
2014-04-03 10:12:22 +00:00
|
|
|
|
|
|
|
public static ISound playSound(SoundManager manager, ISound sound)
|
|
|
|
{
|
|
|
|
SoundEventAccessorComposite accessor = manager.sndHandler.getSound(sound.getPositionedSoundLocation());
|
|
|
|
PlaySoundEvent17 e = new PlaySoundEvent17(manager, sound, (accessor == null ? null : accessor.getSoundCategory()));
|
|
|
|
MinecraftForge.EVENT_BUS.post(e);
|
|
|
|
return e.result;
|
|
|
|
}
|
2014-05-20 17:51:46 +00:00
|
|
|
|
|
|
|
static RenderBlocks worldRendererRB;
|
|
|
|
static int worldRenderPass;
|
|
|
|
|
|
|
|
public static int getWorldRenderPass()
|
|
|
|
{
|
|
|
|
return worldRenderPass;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setWorldRendererRB(RenderBlocks renderBlocks)
|
|
|
|
{
|
|
|
|
worldRendererRB = renderBlocks;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void onPreRenderWorld(WorldRenderer worldRenderer, int pass)
|
|
|
|
{
|
|
|
|
if(worldRendererRB != null)
|
|
|
|
{
|
|
|
|
worldRenderPass = pass;
|
|
|
|
MinecraftForge.EVENT_BUS.post(new RenderWorldEvent.Pre(worldRenderer, (ChunkCache)worldRendererRB.blockAccess, worldRendererRB, pass));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void onPostRenderWorld(WorldRenderer worldRenderer, int pass)
|
|
|
|
{
|
|
|
|
if(worldRendererRB != null)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new RenderWorldEvent.Post(worldRenderer, (ChunkCache)worldRendererRB.blockAccess, worldRendererRB, pass));
|
|
|
|
worldRenderPass = -1;
|
|
|
|
}
|
|
|
|
}
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|