2012-08-06 10:35:57 +00:00
|
|
|
package net.minecraftforge.client;
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import static net.minecraftforge.common.ForgeVersion.Status.BETA;
|
|
|
|
import static net.minecraftforge.common.ForgeVersion.Status.BETA_OUTDATED;
|
2014-12-28 04:10:54 +00:00
|
|
|
import static org.lwjgl.opengl.GL11.*;
|
|
|
|
import static org.lwjgl.opengl.GL20.*;
|
|
|
|
|
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
import java.nio.FloatBuffer;
|
2015-09-02 04:26:42 +00:00
|
|
|
import java.util.Map;
|
2014-12-28 04:10:54 +00:00
|
|
|
|
|
|
|
import javax.vecmath.Matrix4f;
|
2015-10-27 21:29:16 +00:00
|
|
|
import javax.vecmath.Vector3f;
|
2015-02-14 01:44:09 +00:00
|
|
|
import javax.vecmath.Vector4f;
|
2014-12-28 04:10:54 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.client.Minecraft;
|
2014-04-03 10:12:22 +00:00
|
|
|
import net.minecraft.client.audio.ISound;
|
|
|
|
import net.minecraft.client.audio.SoundManager;
|
2013-12-25 08:35:59 +00:00
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
|
|
|
import net.minecraft.client.gui.GuiMainMenu;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.client.gui.GuiScreen;
|
2015-11-12 15:24:15 +00:00
|
|
|
import net.minecraft.client.model.ModelBiped;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.client.renderer.EntityRenderer;
|
2014-12-28 04:10:54 +00:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
|
|
import net.minecraft.client.renderer.OpenGlHelper;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.client.renderer.RenderGlobal;
|
2016-03-01 16:22:21 +00:00
|
|
|
import net.minecraft.client.renderer.VertexBuffer;
|
2015-02-17 01:56:32 +00:00
|
|
|
import net.minecraft.client.renderer.block.model.BakedQuad;
|
2016-03-01 12:58:03 +00:00
|
|
|
import net.minecraft.client.renderer.block.model.IBakedModel;
|
2014-12-28 04:10:54 +00:00
|
|
|
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
|
|
|
import net.minecraft.client.renderer.block.model.ItemTransformVec3f;
|
2016-03-01 12:58:03 +00:00
|
|
|
import net.minecraft.client.renderer.block.model.ModelBakery;
|
|
|
|
import net.minecraft.client.renderer.block.model.ModelManager;
|
|
|
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
|
|
|
import net.minecraft.client.renderer.block.model.ModelRotation;
|
2016-03-01 16:22:21 +00:00
|
|
|
import net.minecraft.client.renderer.block.model.SimpleBakedModel;
|
|
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.client.renderer.texture.TextureManager;
|
|
|
|
import net.minecraft.client.renderer.texture.TextureMap;
|
2015-09-02 04:26:42 +00:00
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
2015-11-09 21:03:39 +00:00
|
|
|
import net.minecraft.client.renderer.vertex.VertexFormat;
|
2014-12-28 04:10:54 +00:00
|
|
|
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
|
|
|
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.client.resources.I18n;
|
|
|
|
import net.minecraft.client.settings.GameSettings;
|
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;
|
2016-03-01 17:52:19 +00:00
|
|
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
2015-09-02 04:26:42 +00:00
|
|
|
import net.minecraft.item.Item;
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-09-02 04:26:42 +00:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-02-12 21:48:51 +00:00
|
|
|
import net.minecraft.util.*;
|
2016-03-01 12:58:03 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
|
|
|
import net.minecraft.util.registry.IRegistry;
|
|
|
|
import net.minecraft.util.text.TextFormatting;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2013-09-14 03:11:59 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraft.world.biome.BiomeGenBase;
|
2012-08-23 01:02:14 +00:00
|
|
|
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
|
|
|
import net.minecraftforge.client.event.FOVUpdateEvent;
|
|
|
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
2014-11-27 03:56:35 +00:00
|
|
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraftforge.client.event.MouseEvent;
|
2014-02-21 17:13:40 +00:00
|
|
|
import net.minecraftforge.client.event.RenderHandEvent;
|
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;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraftforge.client.event.sound.PlaySoundEvent;
|
2015-12-03 19:38:08 +00:00
|
|
|
import net.minecraftforge.client.model.IModelPart;
|
2014-12-28 04:10:54 +00:00
|
|
|
import net.minecraftforge.client.model.IPerspectiveAwareModel;
|
2015-02-04 06:45:23 +00:00
|
|
|
import net.minecraftforge.client.model.ModelLoader;
|
2015-11-09 21:03:39 +00:00
|
|
|
import net.minecraftforge.client.model.TRSRTransformation;
|
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;
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
2016-02-12 21:48:51 +00:00
|
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
2014-12-28 04:10:54 +00:00
|
|
|
import net.minecraftforge.fml.common.FMLLog;
|
2014-11-27 03:56:35 +00:00
|
|
|
|
2014-12-28 04:10:54 +00:00
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
|
import org.lwjgl.BufferUtils;
|
2015-11-13 14:23:37 +00:00
|
|
|
|
2016-03-01 16:22:21 +00:00
|
|
|
import com.google.common.base.Objects;
|
2015-12-03 19:38:08 +00:00
|
|
|
import com.google.common.base.Optional;
|
2015-09-02 04:26:42 +00:00
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
2015-11-27 03:37:44 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
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
|
|
|
|
2016-03-01 17:52:19 +00:00
|
|
|
public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EntityEquipmentSlot slot, String type)
|
2013-07-24 20:12:38 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
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.
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static void orientBedCamera(IBlockAccess world, BlockPos pos, IBlockState state, Entity entity)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
Block block = state.getBlock();
|
2012-08-23 01:02:14 +00:00
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (block != null && block.isBed(world, pos, entity))
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
2015-12-03 19:38:08 +00:00
|
|
|
glRotatef((float)(block.getBedDirection(world, pos).getHorizontalIndex() * 90), 0.0F, 1.0F, 0.0F);
|
2012-08-23 01:02:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-01 17:52:19 +00:00
|
|
|
public static boolean onDrawBlockHighlight(RenderGlobal context, EntityPlayer player, RayTraceResult target, int subID, float partialTicks)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
2016-03-01 17:52:19 +00:00
|
|
|
return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent(context, player, target, subID, partialTicks));
|
2012-08-23 01:02:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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));
|
2015-02-17 18:20:14 +00:00
|
|
|
ModelLoader.White.instance.register(map);
|
2013-03-18 03:07:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void onTextureStitchedPost(TextureMap map)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Post(map));
|
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
|
|
|
|
2016-03-01 12:58:03 +00:00
|
|
|
static final ThreadLocal<BlockRenderLayer> renderLayer = new ThreadLocal<BlockRenderLayer>()
|
2015-02-08 23:46:01 +00:00
|
|
|
{
|
2016-03-01 12:58:03 +00:00
|
|
|
protected BlockRenderLayer initialValue()
|
2015-02-08 23:46:01 +00:00
|
|
|
{
|
2016-03-01 12:58:03 +00:00
|
|
|
return BlockRenderLayer.SOLID;
|
2015-02-08 23:46:01 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-03-01 12:58:03 +00:00
|
|
|
public static void setRenderLayer(BlockRenderLayer layer)
|
2014-12-26 05:39:12 +00:00
|
|
|
{
|
2015-02-08 23:46:01 +00:00
|
|
|
renderLayer.set(layer);
|
2014-12-26 05:39:12 +00:00
|
|
|
}
|
|
|
|
|
2016-03-01 17:52:19 +00:00
|
|
|
public static ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot slot, ModelBiped _default)
|
2013-05-09 00:13:19 +00:00
|
|
|
{
|
2016-03-01 17:52:19 +00:00
|
|
|
ModelBiped model = itemStack.getItem().getArmorModel(entityLiving, itemStack, slot, _default);
|
2015-11-12 15:24:15 +00:00
|
|
|
return model == null ? _default : model;
|
2013-05-09 00:13:19 +00:00
|
|
|
}
|
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());
|
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static float getOffsetFOV(EntityPlayer entity, float fov)
|
2013-09-06 00:14:24 +00:00
|
|
|
{
|
|
|
|
FOVUpdateEvent fovUpdateEvent = new FOVUpdateEvent(entity, fov);
|
|
|
|
MinecraftForge.EVENT_BUS.post(fovUpdateEvent);
|
|
|
|
return fovUpdateEvent.newfov;
|
|
|
|
}
|
2016-03-01 12:58:03 +00:00
|
|
|
|
2016-03-01 17:52:19 +00:00
|
|
|
public static float getFOVModifier(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, float fov) {
|
|
|
|
EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, entity, state, renderPartialTicks, fov);
|
2016-02-16 13:52:41 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
return event.getFOV();
|
|
|
|
}
|
2013-09-06 00:14:24 +00:00
|
|
|
|
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
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static int getSkyBlendColour(World world, BlockPos center)
|
2013-09-14 03:11:59 +00:00
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (center.getX() == skyX && center.getZ() == skyZ && skyInit)
|
2013-09-14 03:11:59 +00:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
BlockPos pos = center.add(x, 0, z);
|
|
|
|
BiomeGenBase biome = world.getBiomeGenForCoords(pos);
|
2014-12-02 03:11:17 +00:00
|
|
|
int colour = biome.getSkyColorByTemp(biome.getFloatTemperature(pos));
|
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
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
skyX = center.getX();
|
|
|
|
skyZ = center.getY();
|
2013-09-14 03:11:59 +00:00
|
|
|
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
|
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +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,
|
2016-03-01 12:58:03 +00:00
|
|
|
String line = I18n.format("forge.update.beta.1", TextFormatting.RED, TextFormatting.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)
|
|
|
|
{
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
SoundEventAccessorComposite accessor = manager.sndHandler.getSound(sound.getSoundLocation());
|
|
|
|
PlaySoundEvent e = new PlaySoundEvent(manager, sound, (accessor == null ? null : accessor.getSoundCategory()));
|
2014-04-03 10:12:22 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(e);
|
|
|
|
return e.result;
|
|
|
|
}
|
2014-05-20 17:51:46 +00:00
|
|
|
|
2016-03-01 12:58:03 +00:00
|
|
|
//static RenderBlocks VertexBufferRB;
|
2014-05-20 17:51:46 +00:00
|
|
|
static int worldRenderPass;
|
|
|
|
|
|
|
|
public static int getWorldRenderPass()
|
|
|
|
{
|
|
|
|
return worldRenderPass;
|
|
|
|
}
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
public static void drawScreen(GuiScreen screen, int mouseX, int mouseY, float partialTicks)
|
|
|
|
{
|
|
|
|
if (!MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Pre(screen, mouseX, mouseY, partialTicks)))
|
|
|
|
screen.drawScreen(mouseX, mouseY, partialTicks);
|
|
|
|
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(screen, mouseX, mouseY, partialTicks));
|
|
|
|
}
|
|
|
|
|
2016-03-01 17:52:19 +00:00
|
|
|
public static float getFogDensity(EntityRenderer renderer, Entity entity, IBlockState state, float partial, float density)
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
{
|
2016-03-01 17:52:19 +00:00
|
|
|
EntityViewRenderEvent.FogDensity event = new EntityViewRenderEvent.FogDensity(renderer, entity, state, partial, density);
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
if (MinecraftForge.EVENT_BUS.post(event)) return event.density;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-03-01 17:52:19 +00:00
|
|
|
public static void onFogRender(EntityRenderer renderer, Entity entity, IBlockState state, float partial, int mode, float distance)
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
{
|
2016-03-01 17:52:19 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(new EntityViewRenderEvent.RenderFogEvent(renderer, entity, state, partial, mode, distance));
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-03-01 12:58:03 +00:00
|
|
|
public static void setVertexBufferRB(RenderBlocks renderBlocks)
|
2014-05-20 17:51:46 +00:00
|
|
|
{
|
2016-03-01 12:58:03 +00:00
|
|
|
VertexBufferRB = renderBlocks;
|
2014-05-20 17:51:46 +00:00
|
|
|
}
|
|
|
|
|
2016-03-01 12:58:03 +00:00
|
|
|
public static void onPreRenderWorld(VertexBuffer VertexBuffer, int pass)
|
2014-05-20 17:51:46 +00:00
|
|
|
{
|
2016-03-01 12:58:03 +00:00
|
|
|
if(VertexBufferRB != null)
|
2014-05-20 17:51:46 +00:00
|
|
|
{
|
|
|
|
worldRenderPass = pass;
|
2016-03-01 12:58:03 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(new RenderWorldEvent.Pre(VertexBuffer, (ChunkCache)VertexBufferRB.blockAccess, VertexBufferRB, pass));
|
2014-05-20 17:51:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-01 12:58:03 +00:00
|
|
|
public static void onPostRenderWorld(VertexBuffer VertexBuffer, int pass)
|
2014-05-20 17:51:46 +00:00
|
|
|
{
|
2016-03-01 12:58:03 +00:00
|
|
|
if(VertexBufferRB != null)
|
2014-05-20 17:51:46 +00:00
|
|
|
{
|
2016-03-01 12:58:03 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(new RenderWorldEvent.Post(VertexBuffer, (ChunkCache)VertexBufferRB.blockAccess, VertexBufferRB, pass));
|
2014-05-20 17:51:46 +00:00
|
|
|
worldRenderPass = -1;
|
|
|
|
}
|
|
|
|
}
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
*/
|
2014-11-27 03:56:35 +00:00
|
|
|
|
2016-03-05 23:51:39 +00:00
|
|
|
public static void onModelBake(ModelManager modelManager, IRegistry<ModelResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
|
2014-11-27 03:56:35 +00:00
|
|
|
{
|
2016-03-05 23:51:39 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(new ModelBakeEvent(modelManager, modelRegistry, modelLoader));
|
|
|
|
modelLoader.onPostBakeEvent(modelRegistry);
|
2014-11-27 03:56:35 +00:00
|
|
|
}
|
2014-12-28 04:10:54 +00:00
|
|
|
|
2015-11-27 03:37:44 +00:00
|
|
|
public static Matrix4f getMatrix(ItemTransformVec3f transform)
|
2014-12-28 04:10:54 +00:00
|
|
|
{
|
|
|
|
javax.vecmath.Matrix4f m = new javax.vecmath.Matrix4f(), t = new javax.vecmath.Matrix4f();
|
|
|
|
m.setIdentity();
|
2015-11-09 21:03:39 +00:00
|
|
|
m.setTranslation(TRSRTransformation.toVecmath(transform.translation));
|
2014-12-28 04:10:54 +00:00
|
|
|
t.setIdentity();
|
|
|
|
t.rotY(transform.rotation.y);
|
|
|
|
m.mul(t);
|
|
|
|
t.setIdentity();
|
|
|
|
t.rotX(transform.rotation.x);
|
|
|
|
m.mul(t);
|
|
|
|
t.setIdentity();
|
|
|
|
t.rotZ(transform.rotation.z);
|
|
|
|
m.mul(t);
|
|
|
|
t.setIdentity();
|
|
|
|
t.m00 = transform.scale.x;
|
|
|
|
t.m11 = transform.scale.y;
|
|
|
|
t.m22 = transform.scale.z;
|
|
|
|
m.mul(t);
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2015-11-27 03:37:44 +00:00
|
|
|
public static IBakedModel handleCameraTransforms(IBakedModel model, ItemCameraTransforms.TransformType cameraTransformType)
|
2014-12-28 04:10:54 +00:00
|
|
|
{
|
|
|
|
if(model instanceof IPerspectiveAwareModel)
|
|
|
|
{
|
2016-03-05 23:51:39 +00:00
|
|
|
Pair<? extends IBakedModel, Matrix4f> pair = ((IPerspectiveAwareModel)model).handlePerspective(cameraTransformType);
|
2014-12-28 04:10:54 +00:00
|
|
|
|
|
|
|
if(pair.getRight() != null) multiplyCurrentGlMatrix(pair.getRight());
|
|
|
|
return pair.getLeft();
|
|
|
|
}
|
2015-11-08 06:37:33 +00:00
|
|
|
else
|
2014-12-28 04:10:54 +00:00
|
|
|
{
|
2015-12-30 04:15:03 +00:00
|
|
|
model.getItemCameraTransforms().applyTransform(cameraTransformType);
|
2014-12-28 04:10:54 +00:00
|
|
|
}
|
|
|
|
return model;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static final FloatBuffer matrixBuf = BufferUtils.createFloatBuffer(16);
|
|
|
|
|
|
|
|
public static void multiplyCurrentGlMatrix(Matrix4f matrix)
|
|
|
|
{
|
|
|
|
matrixBuf.clear();
|
|
|
|
float[] t = new float[4];
|
|
|
|
for(int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
matrix.getColumn(i, t);
|
|
|
|
matrixBuf.put(t);
|
|
|
|
}
|
|
|
|
matrixBuf.flip();
|
2015-12-03 19:38:08 +00:00
|
|
|
glMultMatrix(matrixBuf);
|
2014-12-28 04:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// moved and expanded from WorldVertexBufferUploader.draw
|
|
|
|
|
2015-11-09 21:03:39 +00:00
|
|
|
public static void preDraw(EnumUsage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer)
|
2014-12-28 04:10:54 +00:00
|
|
|
{
|
2015-11-09 21:03:39 +00:00
|
|
|
VertexFormatElement attr = format.getElement(element);
|
2016-01-01 15:15:48 +00:00
|
|
|
int count = attr.getElementCount();
|
|
|
|
int constant = attr.getType().getGlConstant();
|
2015-11-09 21:03:39 +00:00
|
|
|
buffer.position(format.func_181720_d(element));
|
2014-12-28 04:10:54 +00:00
|
|
|
switch(attrType)
|
|
|
|
{
|
|
|
|
case POSITION:
|
2016-01-01 15:15:48 +00:00
|
|
|
glVertexPointer(count, constant, stride, buffer);
|
2014-12-28 04:10:54 +00:00
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
|
|
|
break;
|
|
|
|
case NORMAL:
|
2016-01-01 15:15:48 +00:00
|
|
|
if(count != 3)
|
2014-12-28 04:10:54 +00:00
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("Normal attribute should have the size 3: " + attr);
|
|
|
|
}
|
2016-01-01 15:15:48 +00:00
|
|
|
glNormalPointer(constant, stride, buffer);
|
2014-12-28 04:10:54 +00:00
|
|
|
glEnableClientState(GL_NORMAL_ARRAY);
|
|
|
|
break;
|
|
|
|
case COLOR:
|
2016-01-01 15:15:48 +00:00
|
|
|
glColorPointer(count, constant, stride, buffer);
|
2014-12-28 04:10:54 +00:00
|
|
|
glEnableClientState(GL_COLOR_ARRAY);
|
|
|
|
break;
|
|
|
|
case UV:
|
|
|
|
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + attr.getIndex());
|
2016-01-01 15:15:48 +00:00
|
|
|
glTexCoordPointer(count, constant, stride, buffer);
|
2014-12-28 04:10:54 +00:00
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
|
|
|
|
break;
|
|
|
|
case PADDING:
|
|
|
|
break;
|
|
|
|
case GENERIC:
|
|
|
|
glEnableVertexAttribArray(attr.getIndex());
|
2016-01-01 15:15:48 +00:00
|
|
|
glVertexAttribPointer(attr.getIndex(), count, constant, false, stride, buffer);
|
2014-12-28 04:10:54 +00:00
|
|
|
default:
|
|
|
|
FMLLog.severe("Unimplemented vanilla attribute upload: %s", attrType.getDisplayName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-09 21:03:39 +00:00
|
|
|
public static void postDraw(EnumUsage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer)
|
2014-12-28 04:10:54 +00:00
|
|
|
{
|
2015-11-09 21:03:39 +00:00
|
|
|
VertexFormatElement attr = format.getElement(element);
|
2014-12-28 04:10:54 +00:00
|
|
|
switch(attrType)
|
|
|
|
{
|
|
|
|
case POSITION:
|
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
|
|
|
break;
|
|
|
|
case NORMAL:
|
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
|
|
|
break;
|
|
|
|
case COLOR:
|
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
|
|
|
// is this really needed?
|
|
|
|
GlStateManager.resetColor();
|
|
|
|
break;
|
|
|
|
case UV:
|
|
|
|
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + attr.getIndex());
|
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
|
|
|
|
break;
|
|
|
|
case PADDING:
|
|
|
|
break;
|
|
|
|
case GENERIC:
|
|
|
|
glDisableVertexAttribArray(attr.getIndex());
|
|
|
|
default:
|
|
|
|
FMLLog.severe("Unimplemented vanilla attribute upload: %s", attrType.getDisplayName());
|
|
|
|
}
|
|
|
|
}
|
2015-02-14 01:44:09 +00:00
|
|
|
|
2015-11-09 21:03:39 +00:00
|
|
|
public static void transform(org.lwjgl.util.vector.Vector3f vec, Matrix4f m)
|
2015-02-14 01:44:09 +00:00
|
|
|
{
|
2015-11-09 21:03:39 +00:00
|
|
|
Vector4f tmp = new Vector4f(vec.x, vec.y, vec.z, 1f);
|
2015-02-14 01:44:09 +00:00
|
|
|
m.transform(tmp);
|
|
|
|
if(Math.abs(tmp.w - 1f) > 1e-5) tmp.scale(1f / tmp.w);
|
|
|
|
vec.set(tmp.x, tmp.y, tmp.z);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Matrix4f getMatrix(ModelRotation modelRotation)
|
|
|
|
{
|
2015-11-09 21:03:39 +00:00
|
|
|
Matrix4f ret = new Matrix4f(TRSRTransformation.toVecmath(modelRotation.getMatrix4d())), tmp = new Matrix4f();
|
2015-02-14 01:44:09 +00:00
|
|
|
tmp.setIdentity();
|
|
|
|
tmp.m03 = tmp.m13 = tmp.m23 = .5f;
|
|
|
|
ret.mul(tmp, ret);
|
|
|
|
tmp.invert();
|
|
|
|
//tmp.m03 = tmp.m13 = tmp.m23 = -.5f;
|
|
|
|
ret.mul(tmp);
|
|
|
|
return ret;
|
|
|
|
}
|
2015-02-17 01:56:32 +00:00
|
|
|
|
2016-03-01 12:58:03 +00:00
|
|
|
public static void putQuadColor(VertexBuffer renderer, BakedQuad quad, int color)
|
2015-02-17 01:56:32 +00:00
|
|
|
{
|
|
|
|
float cr = color & 0xFF;
|
|
|
|
float cg = (color >>> 8) & 0xFF;
|
|
|
|
float cb = (color >>> 16) & 0xFF;
|
|
|
|
float ca = (color >>> 24) & 0xFF;
|
|
|
|
for(int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
int vc = quad.getVertexData()[3 + 7 * i];
|
|
|
|
float vcr = vc & 0xFF;
|
|
|
|
float vcg = (vc >>> 8) & 0xFF;
|
|
|
|
float vcb = (vc >>> 16) & 0xFF;
|
|
|
|
float vca = (vc >>> 24) & 0xFF;
|
|
|
|
int ncr = Math.min(0xFF, (int)(cr * vcr / 0xFF));
|
|
|
|
int ncg = Math.min(0xFF, (int)(cg * vcg / 0xFF));
|
|
|
|
int ncb = Math.min(0xFF, (int)(cb * vcb / 0xFF));
|
|
|
|
int nca = Math.min(0xFF, (int)(ca * vca / 0xFF));
|
2015-06-28 22:19:10 +00:00
|
|
|
renderer.putColorRGBA(renderer.getColorIndex(4 - i), ncr, ncg, ncb, nca);
|
2015-02-17 01:56:32 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-02 04:26:42 +00:00
|
|
|
|
|
|
|
private static Map<Pair<Item, Integer>, Class<? extends TileEntity>> tileItemMap = Maps.newHashMap();
|
|
|
|
|
|
|
|
public static void renderTileItem(Item item, int metadata)
|
|
|
|
{
|
2015-11-27 03:37:44 +00:00
|
|
|
Class<? extends TileEntity> tileClass = tileItemMap.get(Pair.of(item, metadata));
|
2015-09-02 04:26:42 +00:00
|
|
|
if (tileClass != null)
|
|
|
|
{
|
2015-12-03 19:38:08 +00:00
|
|
|
TileEntitySpecialRenderer<?> r = TileEntityRendererDispatcher.instance.getSpecialRendererByClass(tileClass);
|
2015-09-02 04:26:42 +00:00
|
|
|
if (r != null)
|
|
|
|
{
|
|
|
|
r.renderTileEntityAt(null, 0, 0, 0, 0, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated Will be removed as soon as possible, hopefully 1.9.
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public static void registerTESRItemStack(Item item, int metadata, Class<? extends TileEntity> TileClass)
|
|
|
|
{
|
|
|
|
tileItemMap.put(Pair.of(item, metadata), TileClass);
|
|
|
|
}
|
2015-06-28 22:19:10 +00:00
|
|
|
|
2015-10-27 21:29:16 +00:00
|
|
|
/**
|
|
|
|
* internal, relies on fixed format of FaceBakery
|
|
|
|
*/
|
2015-06-28 22:19:10 +00:00
|
|
|
public static void fillNormal(int[] faceData, EnumFacing facing)
|
|
|
|
{
|
2015-10-27 21:29:16 +00:00
|
|
|
Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
|
|
|
|
Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
|
|
|
|
Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
|
|
|
|
v1.sub(t);
|
|
|
|
t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
|
|
|
|
v2.sub(t);
|
|
|
|
v1.cross(v2, v1);
|
|
|
|
v1.normalize();
|
|
|
|
|
|
|
|
int x = ((byte)(v1.x * 127)) & 0xFF;
|
|
|
|
int y = ((byte)(v1.y * 127)) & 0xFF;
|
|
|
|
int z = ((byte)(v1.z * 127)) & 0xFF;
|
2015-06-28 22:19:10 +00:00
|
|
|
for(int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
|
|
|
|
}
|
|
|
|
}
|
2015-12-03 19:38:08 +00:00
|
|
|
|
|
|
|
public static Optional<TRSRTransformation> applyTransform(ItemTransformVec3f transform, Optional<? extends IModelPart> part)
|
|
|
|
{
|
|
|
|
if(part.isPresent()) return Optional.absent();
|
|
|
|
return Optional.of(new TRSRTransformation(transform));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Optional<TRSRTransformation> applyTransform(Matrix4f matrix, Optional<? extends IModelPart> part)
|
|
|
|
{
|
|
|
|
if(part.isPresent()) return Optional.absent();
|
|
|
|
return Optional.of(new TRSRTransformation(matrix));
|
|
|
|
}
|
2016-02-12 21:48:51 +00:00
|
|
|
|
2016-02-14 14:02:45 +00:00
|
|
|
public static void loadEntityShader(Entity entity, EntityRenderer entityRenderer)
|
2016-02-12 21:48:51 +00:00
|
|
|
{
|
2016-02-14 14:02:45 +00:00
|
|
|
if (entity != null)
|
2016-02-12 21:48:51 +00:00
|
|
|
{
|
2016-02-14 14:02:45 +00:00
|
|
|
ResourceLocation shader = ClientRegistry.getEntityShader(entity.getClass());
|
|
|
|
if (shader != null)
|
|
|
|
{
|
|
|
|
entityRenderer.loadShader(shader);
|
|
|
|
}
|
2016-02-12 21:48:51 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-01 16:22:21 +00:00
|
|
|
|
|
|
|
public static IBakedModel getDamageModel(IBakedModel ibakedmodel, TextureAtlasSprite texture, IBlockState state, IBlockAccess world, BlockPos pos)
|
|
|
|
{
|
|
|
|
// TODO custom damage models
|
|
|
|
// state = state.block.getExtendedState(state, world, pos);
|
|
|
|
return (new SimpleBakedModel.Builder(state, ibakedmodel, texture, pos)).makeBakedModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean shouldCauseReequipAnimation(ItemStack from, ItemStack to)
|
|
|
|
{
|
|
|
|
if(!Objects.equal(from, to) || from == null)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// FIXME: 3rd argument?
|
|
|
|
return from.getItem().shouldCauseReequipAnimation(from, to);
|
|
|
|
}
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|