2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
|
|
|
* Copyright (c) 2016.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2012-08-06 10:35:57 +00:00
|
|
|
package net.minecraftforge.client;
|
|
|
|
|
2016-04-15 05:34:46 +00:00
|
|
|
import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.BOSSINFO;
|
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.*;
|
|
|
|
|
2016-05-09 21:51:30 +00:00
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import java.io.File;
|
2014-12-28 04:10:54 +00:00
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
import java.nio.FloatBuffer;
|
2016-05-04 01:26:52 +00:00
|
|
|
import java.util.Collections;
|
2015-09-02 04:26:42 +00:00
|
|
|
import java.util.Map;
|
2014-12-28 04:10:54 +00:00
|
|
|
|
2016-03-21 15:06:31 +00:00
|
|
|
import javax.vecmath.Matrix3f;
|
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;
|
2016-04-15 05:34:46 +00:00
|
|
|
import net.minecraft.client.gui.ScaledResolution;
|
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-21 15:06:31 +00:00
|
|
|
import net.minecraft.client.renderer.block.model.BlockFaceUV;
|
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;
|
2016-03-01 12:58:03 +00:00
|
|
|
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-03-21 15:06:31 +00:00
|
|
|
import net.minecraft.util.BlockRenderLayer;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2016-03-01 12:58:03 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2016-03-21 15:06:31 +00:00
|
|
|
import net.minecraft.util.math.MathHelper;
|
2016-03-01 12:58:03 +00:00
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
|
|
|
import net.minecraft.util.registry.IRegistry;
|
|
|
|
import net.minecraft.util.text.TextFormatting;
|
2016-04-15 05:34:46 +00:00
|
|
|
import net.minecraft.world.BossInfoLerping;
|
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;
|
2016-05-18 10:29:10 +00:00
|
|
|
import net.minecraft.world.biome.Biome;
|
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;
|
2016-04-15 05:34:46 +00:00
|
|
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
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;
|
2016-05-09 21:51:30 +00:00
|
|
|
import net.minecraftforge.client.event.ScreenshotEvent;
|
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;
|
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;
|
2016-04-15 05:34:46 +00:00
|
|
|
import net.minecraftforge.client.model.animation.Animation;
|
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;
|
2016-03-21 15:06:31 +00:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2016-03-21 07:01:30 +00:00
|
|
|
import net.minecraftforge.common.model.IModelPart;
|
2016-03-21 15:06:31 +00:00
|
|
|
import net.minecraftforge.common.model.ITransformation;
|
2016-03-21 07:01:30 +00:00
|
|
|
import net.minecraftforge.common.model.TRSRTransformation;
|
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-05-04 01:26:52 +00:00
|
|
|
import net.minecraftforge.fml.client.GuiJava8Error;
|
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;
|
2016-05-04 01:26:52 +00:00
|
|
|
import net.minecraftforge.fml.common.Java8VersionException;
|
|
|
|
import net.minecraftforge.fml.common.Loader;
|
|
|
|
import net.minecraftforge.fml.common.ModContainer;
|
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
|
|
|
|
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;
|
|
|
|
|
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
|
2016-03-23 14:34:48 +00:00
|
|
|
//Note: When using Optifine, these methods are invoked using reflection, which
|
2012-08-23 01:02:14 +00:00
|
|
|
//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
|
|
|
|
2016-03-08 07:34:40 +00:00
|
|
|
if (block != null && block.isBed(state, world, pos, entity))
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
2016-03-08 07:34:40 +00:00
|
|
|
glRotatef((float)(block.getBedDirection(state, 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));
|
2016-03-21 07:23:27 +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-17 04:28:19 +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
|
|
|
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);
|
2016-03-24 08:44:52 +00:00
|
|
|
return fovUpdateEvent.getNewfov();
|
2013-09-06 00:14:24 +00:00
|
|
|
}
|
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);
|
2016-05-18 10:29:10 +00:00
|
|
|
Biome 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
|
|
|
|
2016-05-04 01:26:52 +00:00
|
|
|
private static int updatescrollcounter = 0;
|
|
|
|
public static String renderMainMenu(GuiMainMenu gui, FontRenderer font, int width, int height, String splashText)
|
2013-12-25 08:35:59 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-05-04 01:26:52 +00:00
|
|
|
if (!Loader.instance().java8)
|
|
|
|
{
|
|
|
|
String line = I18n.format("fml.messages.java8warning.1", TextFormatting.RED, TextFormatting.RESET);
|
|
|
|
gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (8 * (font.FONT_HEIGHT + 1)), -1);
|
|
|
|
line = I18n.format("fml.messages.java8warning.2");
|
|
|
|
gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (9 * (font.FONT_HEIGHT + 1)), -1);
|
|
|
|
splashText = updatescrollcounter < 50 ? "UPDATE!" : "JAVA!";
|
|
|
|
updatescrollcounter+=1;
|
|
|
|
updatescrollcounter%=100;
|
|
|
|
}
|
|
|
|
|
2013-12-25 08:35:59 +00:00
|
|
|
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);
|
|
|
|
}
|
2016-05-04 01:26:52 +00:00
|
|
|
|
|
|
|
return splashText;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void mainMenuMouseClick(int mouseX, int mouseY, int mouseButton, FontRenderer font, int width)
|
|
|
|
{
|
|
|
|
if (!Loader.instance().java8)
|
|
|
|
{
|
|
|
|
if (mouseY >= (4 + (8 * 10)) && mouseY < (4 + (10 * 10)))
|
|
|
|
{
|
|
|
|
int w = font.getStringWidth(I18n.format("fml.messages.java8warning.1", TextFormatting.RED, TextFormatting.RESET));
|
|
|
|
w = Math.max(w, font.getStringWidth(I18n.format("fml.messages.java8warning.2")));
|
|
|
|
if (mouseX >= ((width - w) / 2) && mouseX <= ((width + w) / 2))
|
|
|
|
{
|
|
|
|
FMLClientHandler.instance().showGuiScreen(new GuiJava8Error(new Java8VersionException(Collections.<ModContainer>emptyList())));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-25 08:35:59 +00:00
|
|
|
}
|
2014-04-03 10:12:22 +00:00
|
|
|
|
|
|
|
public static ISound playSound(SoundManager manager, ISound sound)
|
|
|
|
{
|
2016-03-08 07:34:40 +00:00
|
|
|
PlaySoundEvent e = new PlaySoundEvent(manager, sound);
|
2014-04-03 10:12:22 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(e);
|
2016-03-24 08:44:52 +00:00
|
|
|
return e.getResultSound();
|
2014-04-03 10:12:22 +00:00
|
|
|
}
|
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);
|
2016-03-24 08:44:52 +00:00
|
|
|
if (MinecraftForge.EVENT_BUS.post(event)) return event.getDensity();
|
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
|
|
|
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-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
|
|
|
|
2016-03-10 00:38:58 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
2016-03-21 15:06:31 +00:00
|
|
|
public static Matrix4f getMatrix(net.minecraft.client.renderer.block.model.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;
|
|
|
|
}
|
|
|
|
|
2016-03-10 01:48:13 +00:00
|
|
|
private static final Matrix4f flipX;
|
|
|
|
static {
|
|
|
|
flipX = new Matrix4f();
|
|
|
|
flipX.setIdentity();
|
|
|
|
flipX.m00 = -1;
|
|
|
|
}
|
|
|
|
|
2016-03-10 00:38:58 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static IBakedModel handleCameraTransforms(IBakedModel model, ItemCameraTransforms.TransformType cameraTransformType, boolean leftHandHackery)
|
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
|
|
|
|
2016-03-13 09:10:50 +00:00
|
|
|
if(pair.getRight() != null)
|
2016-03-10 01:48:13 +00:00
|
|
|
{
|
2016-03-13 09:10:50 +00:00
|
|
|
Matrix4f matrix = new Matrix4f(pair.getRight());
|
|
|
|
if(leftHandHackery)
|
|
|
|
{
|
|
|
|
matrix.mul(flipX, matrix);
|
|
|
|
matrix.mul(matrix, flipX);
|
|
|
|
}
|
2016-03-16 00:58:51 +00:00
|
|
|
multiplyCurrentGlMatrix(matrix);
|
2016-03-10 01:48:13 +00:00
|
|
|
}
|
2014-12-28 04:10:54 +00:00
|
|
|
return pair.getLeft();
|
|
|
|
}
|
2015-11-08 06:37:33 +00:00
|
|
|
else
|
2014-12-28 04:10:54 +00:00
|
|
|
{
|
2016-03-10 01:48:13 +00:00
|
|
|
//if(leftHandHackery) GlStateManager.scale(-1, 1, 1);
|
2016-03-13 01:40:03 +00:00
|
|
|
ItemCameraTransforms.applyTransformSide(model.getItemCameraTransforms().getTransform(cameraTransformType), leftHandHackery);
|
2016-03-10 01:48:13 +00:00
|
|
|
//if(leftHandHackery) GlStateManager.scale(-1, 1, 1);
|
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();
|
2016-03-13 01:40:03 +00:00
|
|
|
buffer.position(format.getOffset(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
|
|
|
{
|
2016-03-17 04:28:19 +00:00
|
|
|
float cb = color & 0xFF;
|
2015-02-17 01:56:32 +00:00
|
|
|
float cg = (color >>> 8) & 0xFF;
|
2016-03-17 04:28:19 +00:00
|
|
|
float cr = (color >>> 16) & 0xFF;
|
2015-02-17 01:56:32 +00:00
|
|
|
float ca = (color >>> 24) & 0xFF;
|
2016-03-17 04:28:19 +00:00
|
|
|
VertexFormat format = quad.getFormat();
|
|
|
|
int size = format.getIntegerSize();
|
|
|
|
int offset = format.getColorOffset() / 4; // assumes that color is aligned
|
2015-02-17 01:56:32 +00:00
|
|
|
for(int i = 0; i < 4; i++)
|
|
|
|
{
|
2016-03-17 04:28:19 +00:00
|
|
|
int vc = quad.getVertexData()[offset + size * i];
|
2015-02-17 01:56:32 +00:00
|
|
|
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
|
|
|
|
2016-03-10 00:38:58 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
2016-03-21 15:06:31 +00:00
|
|
|
public static Optional<TRSRTransformation> applyTransform(net.minecraft.client.renderer.block.model.ItemTransformVec3f transform, Optional<? extends IModelPart> part)
|
2015-12-03 19:38:08 +00:00
|
|
|
{
|
|
|
|
if(part.isPresent()) return Optional.absent();
|
2016-03-21 15:23:27 +00:00
|
|
|
return Optional.of(TRSRTransformation.blockCenterToCorner(new TRSRTransformation(transform)));
|
2015-12-03 19:38:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2016-03-08 07:34:40 +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();
|
|
|
|
}
|
|
|
|
|
2016-03-09 22:11:56 +00:00
|
|
|
private static int slotMainHand = 0;
|
2016-03-10 01:19:54 +00:00
|
|
|
// FIXME
|
2016-03-09 22:11:56 +00:00
|
|
|
public static boolean shouldCauseReequipAnimation(ItemStack from, ItemStack to, int slot)
|
2016-03-08 07:34:40 +00:00
|
|
|
{
|
2016-03-22 03:43:22 +00:00
|
|
|
if (from == null && to != null) return true;
|
|
|
|
if (from == null && to == null) return false;
|
|
|
|
if (from != null && to == null) return true;
|
2016-03-09 22:11:56 +00:00
|
|
|
boolean changed = false;
|
|
|
|
if (slot != -1)
|
|
|
|
{
|
|
|
|
changed = slot != slotMainHand;
|
|
|
|
slotMainHand = slot;
|
|
|
|
}
|
2016-03-22 00:56:48 +00:00
|
|
|
return from.getItem().shouldCauseReequipAnimation(from, to, changed);
|
2016-03-08 07:34:40 +00:00
|
|
|
}
|
2016-03-21 15:06:31 +00:00
|
|
|
|
|
|
|
public static BlockFaceUV applyUVLock(BlockFaceUV blockFaceUV, EnumFacing originalSide, ITransformation rotation)
|
|
|
|
{
|
|
|
|
TRSRTransformation global = new TRSRTransformation(rotation.getMatrix());
|
|
|
|
Matrix4f uv = global.getUVLockTransform(originalSide).getMatrix();
|
|
|
|
Vector4f vec = new Vector4f(0, 0, 0, 1);
|
|
|
|
vec.x = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(0)) / 16;
|
|
|
|
vec.y = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(0)) / 16;
|
|
|
|
uv.transform(vec);
|
|
|
|
float uMin = 16 * vec.x; // / vec.w;
|
|
|
|
float vMin = 16 * vec.y; // / vec.w;
|
|
|
|
vec.x = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(2)) / 16;
|
|
|
|
vec.y = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(2)) / 16;
|
|
|
|
vec.z = 0;
|
|
|
|
vec.w = 1;
|
|
|
|
uv.transform(vec);
|
|
|
|
float uMax = 16 * vec.x; // / vec.w;
|
|
|
|
float vMax = 16 * vec.y; // / vec.w;
|
|
|
|
if(uMin > uMax)
|
|
|
|
{
|
|
|
|
float t = uMin;
|
|
|
|
uMin = uMax;
|
|
|
|
uMax = t;
|
|
|
|
}
|
|
|
|
if(vMin > vMax)
|
|
|
|
{
|
|
|
|
float t = vMin;
|
|
|
|
vMin = vMax;
|
|
|
|
vMax = t;
|
|
|
|
}
|
|
|
|
float a = (float)Math.toRadians(blockFaceUV.rotation);
|
|
|
|
Vector3f rv = new Vector3f(MathHelper.cos(a), MathHelper.sin(a), 0);
|
|
|
|
Matrix3f rot = new Matrix3f();
|
|
|
|
uv.getRotationScale(rot);
|
|
|
|
rot.transform(rv);
|
|
|
|
int angle = MathHelper.normalizeAngle(-(int)Math.round(Math.toDegrees(Math.atan2(rv.y, rv.x)) / 90) * 90, 360);
|
|
|
|
return new BlockFaceUV(new float[]{ uMin, vMin, uMax, vMax }, angle);
|
|
|
|
}
|
2016-04-15 05:34:46 +00:00
|
|
|
|
|
|
|
public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(ScaledResolution res, BossInfoLerping bossInfo, int x, int y, int increment)
|
|
|
|
{
|
|
|
|
RenderGameOverlayEvent.BossInfo evt = new RenderGameOverlayEvent.BossInfo(new RenderGameOverlayEvent(Animation.getPartialTickTime(), res),
|
|
|
|
BOSSINFO, bossInfo, x, y, increment);
|
|
|
|
MinecraftForge.EVENT_BUS.post(evt);
|
|
|
|
return evt;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void bossBarRenderPost(ScaledResolution res)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(new RenderGameOverlayEvent(Animation.getPartialTickTime(), res), BOSSINFO));
|
|
|
|
}
|
2016-05-09 21:51:30 +00:00
|
|
|
|
|
|
|
public static ScreenshotEvent onScreenshot(BufferedImage image, File screenshotFile)
|
|
|
|
{
|
|
|
|
ScreenshotEvent event = new ScreenshotEvent(image, screenshotFile);
|
|
|
|
MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|