2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2018-07-01 21:17:28 +00:00
|
|
|
* Copyright (c) 2016-2018.
|
2016-06-23 03:49:47 +00:00
|
|
|
*
|
|
|
|
* 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;
|
2018-06-11 01:12:46 +00:00
|
|
|
import static net.minecraftforge.fml.VersionChecker.Status.BETA;
|
|
|
|
import static net.minecraftforge.fml.VersionChecker.Status.BETA_OUTDATED;
|
|
|
|
import static org.lwjgl.opengl.GL11.*;
|
|
|
|
import static org.lwjgl.opengl.GL20.*;
|
2014-12-28 04:10:54 +00:00
|
|
|
|
2016-05-09 21:51:30 +00:00
|
|
|
import java.io.File;
|
2014-12-28 04:10:54 +00:00
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
import java.nio.FloatBuffer;
|
2018-07-05 02:59:12 +00:00
|
|
|
import java.util.Optional;
|
2018-09-12 01:42:29 +00:00
|
|
|
import java.util.Random;
|
2014-12-28 04:10:54 +00:00
|
|
|
|
2016-07-24 11:47:34 +00:00
|
|
|
import javax.annotation.Nonnull;
|
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
|
|
|
|
2018-12-24 07:46:42 +00:00
|
|
|
import net.minecraft.client.MouseHelper;
|
2018-12-21 22:45:35 +00:00
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
import org.lwjgl.BufferUtils;
|
|
|
|
|
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.state.IBlockState;
|
2018-09-06 11:39:01 +00:00
|
|
|
import net.minecraft.client.GameSettings;
|
2018-09-21 06:50:50 +00:00
|
|
|
import net.minecraft.client.MainWindow;
|
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.Minecraft;
|
2014-04-03 10:12:22 +00:00
|
|
|
import net.minecraft.client.audio.ISound;
|
|
|
|
import net.minecraft.client.audio.SoundManager;
|
2017-06-05 21:04:10 +00:00
|
|
|
import net.minecraft.client.gui.BossInfoClient;
|
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;
|
2017-06-05 21:04:10 +00:00
|
|
|
import net.minecraft.client.renderer.BufferBuilder;
|
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;
|
2018-12-21 22:45:35 +00:00
|
|
|
import net.minecraft.client.renderer.FogRenderer;
|
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;
|
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;
|
2018-04-01 07:24:37 +00:00
|
|
|
import net.minecraft.client.renderer.block.model.ItemTransformVec3f;
|
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;
|
2017-12-17 01:34:00 +00:00
|
|
|
import net.minecraft.client.renderer.color.BlockColors;
|
|
|
|
import net.minecraft.client.renderer.color.ItemColors;
|
2018-09-08 20:34:59 +00:00
|
|
|
import net.minecraft.client.renderer.entity.model.ModelBiped;
|
2018-11-29 06:15:05 +00:00
|
|
|
import net.minecraft.client.renderer.texture.NativeImage;
|
2016-03-01 16:22:21 +00:00
|
|
|
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.TextureMap;
|
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;
|
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;
|
2018-12-21 22:45:35 +00:00
|
|
|
import net.minecraft.fluid.IFluidState;
|
2016-03-01 17:52:19 +00:00
|
|
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-03-21 15:06:31 +00:00
|
|
|
import net.minecraft.util.BlockRenderLayer;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-07-23 17:29:58 +00:00
|
|
|
import net.minecraft.util.EnumHand;
|
2017-10-31 18:47:47 +00:00
|
|
|
import net.minecraft.util.MovementInput;
|
2016-03-21 15:06:31 +00:00
|
|
|
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;
|
2018-09-08 20:34:59 +00:00
|
|
|
import net.minecraft.world.IWorldReader;
|
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;
|
2017-12-17 01:34:00 +00:00
|
|
|
import net.minecraftforge.client.event.ColorHandlerEvent;
|
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;
|
2017-10-31 18:47:47 +00:00
|
|
|
import net.minecraftforge.client.event.InputUpdateEvent;
|
2014-11-27 03:56:35 +00:00
|
|
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
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;
|
2016-07-24 14:51:58 +00:00
|
|
|
import net.minecraftforge.client.event.RenderSpecificHandEvent;
|
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;
|
2017-10-31 18:03:44 +00:00
|
|
|
import net.minecraftforge.client.model.ModelDynBucket;
|
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;
|
2018-06-21 19:37:32 +00:00
|
|
|
import net.minecraftforge.common.ForgeMod;
|
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;
|
2018-06-11 01:12:46 +00:00
|
|
|
import net.minecraftforge.fml.VersionChecker;
|
2016-02-12 21:48:51 +00:00
|
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
2018-12-24 07:46:42 +00:00
|
|
|
import net.minecraftforge.eventbus.api.Event;
|
2018-11-29 06:15:05 +00:00
|
|
|
import net.minecraftforge.resource.ReloadRequirements;
|
|
|
|
import net.minecraftforge.resource.SelectiveReloadStateHandler;
|
|
|
|
import net.minecraftforge.resource.VanillaResourceType;
|
2018-12-21 22:45:35 +00:00
|
|
|
import net.minecraftforge.versions.forge.ForgeVersion;
|
2015-09-02 04:26:42 +00:00
|
|
|
|
2012-08-06 10:35:57 +00:00
|
|
|
public class ForgeHooksClient
|
|
|
|
{
|
2018-09-12 01:42:29 +00:00
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
2018-09-21 06:50:50 +00:00
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public static boolean renderFirstPersonHand(RenderGlobal context, float partialTicks)
|
2014-02-21 17:13:40 +00:00
|
|
|
{
|
2018-12-21 22:45:35 +00:00
|
|
|
return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(context, partialTicks));
|
2014-02-21 17:13:40 +00:00
|
|
|
}
|
|
|
|
|
2016-07-24 14:51:58 +00:00
|
|
|
public static boolean renderSpecificFirstPersonHand(EnumHand hand, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack)
|
2016-07-23 17:29:58 +00:00
|
|
|
{
|
2016-07-24 14:51:58 +00:00
|
|
|
return MinecraftForge.EVENT_BUS.post(new RenderSpecificHandEvent(hand, partialTicks, interpPitch, swingProgress, equipProgress, stack));
|
2016-07-23 17:29:58 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 03:07:30 +00:00
|
|
|
public static void onTextureStitchedPre(TextureMap map)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Pre(map));
|
2018-09-12 01:42:29 +00:00
|
|
|
// ModelLoader.White.INSTANCE.register(map); // TODO Custom TAS
|
2017-10-31 18:03:44 +00:00
|
|
|
ModelDynBucket.LoaderDynBucket.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
|
|
|
|
2017-12-17 01:34:00 +00:00
|
|
|
public static void onBlockColorsInit(BlockColors blockColors)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new ColorHandlerEvent.Block(blockColors));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void onItemColorsInit(ItemColors itemColors, BlockColors blockColors)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new ColorHandlerEvent.Item(itemColors, blockColors));
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2018-09-12 01:42:29 +00:00
|
|
|
/* TODO mouse input
|
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());
|
|
|
|
}
|
2018-09-12 01:42:29 +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 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
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public static double getFOVModifier(EntityRenderer renderer, Entity entity, IBlockState blockState, IFluidState fluidState, double renderPartialTicks, double fov) {
|
|
|
|
EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, entity, blockState, fluidState, 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
|
|
|
|
2018-09-22 10:40:22 +00:00
|
|
|
GameSettings settings = Minecraft.getInstance().gameSettings;
|
2018-06-21 19:37:32 +00:00
|
|
|
int[] ranges = ForgeMod.blendRanges;
|
2013-12-21 08:10:35 +00:00
|
|
|
int distance = 0;
|
2016-12-02 02:49:34 +00:00
|
|
|
if (settings.fancyGraphics && ranges.length > 0)
|
2013-12-21 08:10:35 +00:00
|
|
|
{
|
2016-12-21 23:52:30 +00:00
|
|
|
distance = ranges[MathHelper.clamp(settings.renderDistanceChunks, 0, ranges.length-1)];
|
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-11-12 15:05:32 +00:00
|
|
|
Biome biome = world.getBiome(pos);
|
2017-10-04 05:08:36 +00:00
|
|
|
int colour = biome.getSkyColorByTemp(biome.getTemperature(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();
|
2016-09-21 19:50:24 +00:00
|
|
|
skyZ = center.getZ();
|
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
|
|
|
{
|
2018-06-11 01:12:46 +00:00
|
|
|
VersionChecker.Status status = ForgeVersion.getStatus();
|
2013-12-25 08:35:59 +00:00
|
|
|
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);
|
|
|
|
}
|
2016-05-04 01:26:52 +00:00
|
|
|
|
|
|
|
return splashText;
|
|
|
|
}
|
|
|
|
|
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)))
|
2018-09-22 10:40:22 +00:00
|
|
|
screen.render(mouseX, mouseY, partialTicks);
|
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
|
|
|
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(screen, mouseX, mouseY, partialTicks));
|
|
|
|
}
|
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public static float getFogDensity(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, 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
|
|
|
{
|
2018-12-21 22:45:35 +00:00
|
|
|
EntityViewRenderEvent.FogDensity event = new EntityViewRenderEvent.FogDensity(fogRenderer, renderer, entity, state, fluidState, 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;
|
|
|
|
}
|
|
|
|
|
2018-12-21 22:45:35 +00:00
|
|
|
public static void onFogRender(FogRenderer fogRenderer, EntityRenderer renderer, Entity entity, IBlockState state, IFluidState fluidState, 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
|
|
|
{
|
2018-12-21 22:45:35 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(new EntityViewRenderEvent.RenderFogEvent(fogRenderer, renderer, entity, state, fluidState, 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
|
|
|
|
2018-06-11 01:12:46 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static Matrix4f getMatrix(net.minecraft.client.renderer.block.model.ItemTransformVec3f transform)
|
|
|
|
{
|
|
|
|
javax.vecmath.Matrix4f m = new javax.vecmath.Matrix4f(), t = new javax.vecmath.Matrix4f();
|
|
|
|
m.setIdentity();
|
|
|
|
m.setTranslation(TRSRTransformation.toVecmath(transform.translation));
|
|
|
|
t.setIdentity();
|
2018-09-22 10:40:22 +00:00
|
|
|
t.rotY(transform.rotation.getY());
|
2018-06-11 01:12:46 +00:00
|
|
|
m.mul(t);
|
|
|
|
t.setIdentity();
|
2018-09-22 10:40:22 +00:00
|
|
|
t.rotX(transform.rotation.getX());
|
2018-06-11 01:12:46 +00:00
|
|
|
m.mul(t);
|
|
|
|
t.setIdentity();
|
2018-09-22 10:40:22 +00:00
|
|
|
t.rotZ(transform.rotation.getZ());
|
2018-06-11 01:12:46 +00:00
|
|
|
m.mul(t);
|
|
|
|
t.setIdentity();
|
2018-09-22 10:40:22 +00:00
|
|
|
t.m00 = transform.scale.getX();
|
|
|
|
t.m11 = transform.scale.getY();
|
|
|
|
t.m22 = transform.scale.getZ();
|
2018-06-11 01:12:46 +00:00
|
|
|
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
|
|
|
public static IBakedModel handleCameraTransforms(IBakedModel model, ItemCameraTransforms.TransformType cameraTransformType, boolean leftHandHackery)
|
2014-12-28 04:10:54 +00:00
|
|
|
{
|
2017-06-25 01:08:20 +00:00
|
|
|
Pair<? extends IBakedModel, Matrix4f> pair = model.handlePerspective(cameraTransformType);
|
2014-12-28 04:10:54 +00:00
|
|
|
|
2017-06-25 01:08:20 +00:00
|
|
|
if (pair.getRight() != null)
|
|
|
|
{
|
|
|
|
Matrix4f matrix = new Matrix4f(pair.getRight());
|
|
|
|
if (leftHandHackery)
|
2016-03-10 01:48:13 +00:00
|
|
|
{
|
2017-06-25 01:08:20 +00:00
|
|
|
matrix.mul(flipX, matrix);
|
|
|
|
matrix.mul(matrix, flipX);
|
2016-03-10 01:48:13 +00:00
|
|
|
}
|
2017-06-25 01:08:20 +00:00
|
|
|
multiplyCurrentGlMatrix(matrix);
|
2014-12-28 04:10:54 +00:00
|
|
|
}
|
2017-06-25 01:08:20 +00:00
|
|
|
return pair.getLeft();
|
2014-12-28 04:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2018-09-12 01:42:29 +00:00
|
|
|
glMultMatrixf(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:
|
2018-06-11 01:12:46 +00:00
|
|
|
glVertexPointer(count, constant, stride, buffer);
|
|
|
|
glEnableClientState(GL_VERTEX_ARRAY);
|
2014-12-28 04:10:54 +00:00
|
|
|
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);
|
|
|
|
}
|
2018-06-11 01:12:46 +00:00
|
|
|
glNormalPointer(constant, stride, buffer);
|
|
|
|
glEnableClientState(GL_NORMAL_ARRAY);
|
2014-12-28 04:10:54 +00:00
|
|
|
break;
|
|
|
|
case COLOR:
|
2018-06-11 01:12:46 +00:00
|
|
|
glColorPointer(count, constant, stride, buffer);
|
|
|
|
glEnableClientState(GL_COLOR_ARRAY);
|
2014-12-28 04:10:54 +00:00
|
|
|
break;
|
|
|
|
case UV:
|
2018-09-22 10:40:22 +00:00
|
|
|
OpenGlHelper.glClientActiveTexture(OpenGlHelper.GL_TEXTURE0 + attr.getIndex());
|
2018-06-11 01:12:46 +00:00
|
|
|
glTexCoordPointer(count, constant, stride, buffer);
|
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
2018-09-22 10:40:22 +00:00
|
|
|
OpenGlHelper.glClientActiveTexture(OpenGlHelper.GL_TEXTURE0);
|
2014-12-28 04:10:54 +00:00
|
|
|
break;
|
|
|
|
case PADDING:
|
|
|
|
break;
|
|
|
|
case GENERIC:
|
2018-06-11 01:12:46 +00:00
|
|
|
glEnableVertexAttribArray(attr.getIndex());
|
|
|
|
glVertexAttribPointer(attr.getIndex(), count, constant, false, stride, buffer);
|
2014-12-28 04:10:54 +00:00
|
|
|
default:
|
2018-09-12 01:42:29 +00:00
|
|
|
LOGGER.fatal("Unimplemented vanilla attribute upload: {}", attrType.getDisplayName());
|
2014-12-28 04:10:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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:
|
2018-06-11 01:12:46 +00:00
|
|
|
glDisableClientState(GL_VERTEX_ARRAY);
|
2014-12-28 04:10:54 +00:00
|
|
|
break;
|
|
|
|
case NORMAL:
|
2018-06-11 01:12:46 +00:00
|
|
|
glDisableClientState(GL_NORMAL_ARRAY);
|
2014-12-28 04:10:54 +00:00
|
|
|
break;
|
|
|
|
case COLOR:
|
2018-06-11 01:12:46 +00:00
|
|
|
glDisableClientState(GL_COLOR_ARRAY);
|
2014-12-28 04:10:54 +00:00
|
|
|
// is this really needed?
|
|
|
|
GlStateManager.resetColor();
|
|
|
|
break;
|
|
|
|
case UV:
|
2018-09-22 10:40:22 +00:00
|
|
|
OpenGlHelper.glClientActiveTexture(OpenGlHelper.GL_TEXTURE0 + attr.getIndex());
|
2018-06-11 01:12:46 +00:00
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
2018-09-22 10:40:22 +00:00
|
|
|
OpenGlHelper.glClientActiveTexture(OpenGlHelper.GL_TEXTURE0);
|
2014-12-28 04:10:54 +00:00
|
|
|
break;
|
|
|
|
case PADDING:
|
|
|
|
break;
|
|
|
|
case GENERIC:
|
2018-06-11 01:12:46 +00:00
|
|
|
glDisableVertexAttribArray(attr.getIndex());
|
2014-12-28 04:10:54 +00:00
|
|
|
default:
|
2018-09-12 01:42:29 +00:00
|
|
|
LOGGER.fatal("Unimplemented vanilla attribute upload: {}", attrType.getDisplayName());
|
2014-12-28 04:10:54 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-14 01:44:09 +00:00
|
|
|
|
2018-09-08 20:34:59 +00:00
|
|
|
public static void transform(net.minecraft.client.renderer.Vector3f vec, Matrix4f m)
|
2015-02-14 01:44:09 +00:00
|
|
|
{
|
2018-09-22 10:40:22 +00:00
|
|
|
Vector4f tmp = new Vector4f(vec.getX(), vec.getY(), vec.getZ(), 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);
|
2018-09-22 10:40:22 +00:00
|
|
|
vec.set(tmp.x, tmp.y, tmp.z);
|
2015-02-14 01:44:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static Matrix4f getMatrix(ModelRotation modelRotation)
|
|
|
|
{
|
2018-09-22 10:40:22 +00:00
|
|
|
Matrix4f ret = new Matrix4f(TRSRTransformation.toVecmath(modelRotation.getMatrix()), new Vector3f(), 1), 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
|
|
|
|
2017-06-05 21:04:10 +00:00
|
|
|
public static void putQuadColor(BufferBuilder 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
|
|
|
|
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)
|
|
|
|
{
|
2017-09-06 21:31:46 +00:00
|
|
|
Vector3f v1 = getVertexPos(faceData, 3);
|
|
|
|
Vector3f t = getVertexPos(faceData, 1);
|
|
|
|
Vector3f v2 = getVertexPos(faceData, 2);
|
2015-10-27 21:29:16 +00:00
|
|
|
v1.sub(t);
|
2017-09-06 21:31:46 +00:00
|
|
|
t.set(getVertexPos(faceData, 0));
|
2015-10-27 21:29:16 +00:00
|
|
|
v2.sub(t);
|
|
|
|
v1.cross(v2, v1);
|
|
|
|
v1.normalize();
|
|
|
|
|
2017-09-06 21:31:46 +00:00
|
|
|
int x = ((byte) Math.round(v1.x * 127)) & 0xFF;
|
|
|
|
int y = ((byte) Math.round(v1.y * 127)) & 0xFF;
|
|
|
|
int z = ((byte) Math.round(v1.z * 127)) & 0xFF;
|
|
|
|
|
|
|
|
int normal = x | (y << 0x08) | (z << 0x10);
|
|
|
|
|
2015-06-28 22:19:10 +00:00
|
|
|
for(int i = 0; i < 4; i++)
|
|
|
|
{
|
2017-09-06 21:31:46 +00:00
|
|
|
faceData[i * 7 + 6] = normal;
|
2015-06-28 22:19:10 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-03 19:38:08 +00:00
|
|
|
|
2017-09-06 21:31:46 +00:00
|
|
|
private static Vector3f getVertexPos(int[] data, int vertex)
|
|
|
|
{
|
|
|
|
int idx = vertex * 7;
|
|
|
|
|
|
|
|
float x = Float.intBitsToFloat(data[idx]);
|
|
|
|
float y = Float.intBitsToFloat(data[idx + 1]);
|
|
|
|
float z = Float.intBitsToFloat(data[idx + 2]);
|
|
|
|
|
|
|
|
return new Vector3f(x, y, z);
|
|
|
|
}
|
|
|
|
|
2016-03-10 00:38:58 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
2018-04-01 07:24:37 +00:00
|
|
|
public static Optional<TRSRTransformation> applyTransform(ItemTransformVec3f transform, Optional<? extends IModelPart> part)
|
2015-12-03 19:38:08 +00:00
|
|
|
{
|
2017-06-25 01:08:20 +00:00
|
|
|
if(part.isPresent()) return Optional.empty();
|
2018-04-01 07:24:37 +00:00
|
|
|
return Optional.of(TRSRTransformation.blockCenterToCorner(TRSRTransformation.from(transform)));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Optional<TRSRTransformation> applyTransform(ModelRotation rotation, Optional<? extends IModelPart> part)
|
|
|
|
{
|
|
|
|
if(part.isPresent()) return Optional.empty();
|
|
|
|
return Optional.of(TRSRTransformation.from(rotation));
|
2015-12-03 19:38:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static Optional<TRSRTransformation> applyTransform(Matrix4f matrix, Optional<? extends IModelPart> part)
|
|
|
|
{
|
2017-06-25 01:08:20 +00:00
|
|
|
if(part.isPresent()) return Optional.empty();
|
2015-12-03 19:38:08 +00:00
|
|
|
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
|
|
|
|
2018-09-12 01:42:29 +00:00
|
|
|
public static IBakedModel getDamageModel(IBakedModel ibakedmodel, TextureAtlasSprite texture, IBlockState state, IWorldReader world, BlockPos pos)
|
2016-03-08 07:34:40 +00:00
|
|
|
{
|
2016-07-28 23:00:36 +00:00
|
|
|
state = state.getBlock().getExtendedState(state, world, pos);
|
2018-09-22 10:40:22 +00:00
|
|
|
return (new SimpleBakedModel.Builder(state, ibakedmodel, texture, new Random(), 42)).build();
|
2016-03-08 07:34:40 +00:00
|
|
|
}
|
|
|
|
|
2016-03-09 22:11:56 +00:00
|
|
|
private static int slotMainHand = 0;
|
2016-12-03 18:47:57 +00:00
|
|
|
|
|
|
|
public static boolean shouldCauseReequipAnimation(@Nonnull ItemStack from, @Nonnull ItemStack to, int slot)
|
2016-03-08 07:34:40 +00:00
|
|
|
{
|
2016-12-21 23:52:30 +00:00
|
|
|
boolean fromInvalid = from.isEmpty();
|
|
|
|
boolean toInvalid = to.isEmpty();
|
2016-12-03 18:47:57 +00:00
|
|
|
|
|
|
|
if (fromInvalid && toInvalid) return false;
|
|
|
|
if (fromInvalid || toInvalid) 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)
|
|
|
|
{
|
2018-09-22 10:40:22 +00:00
|
|
|
TRSRTransformation global = new TRSRTransformation(rotation.getMatrixVec());
|
|
|
|
Matrix4f uv = global.getUVLockTransform(originalSide).getMatrixVec();
|
2016-03-21 15:06:31 +00:00
|
|
|
Vector4f vec = new Vector4f(0, 0, 0, 1);
|
2017-12-17 02:27:33 +00:00
|
|
|
float u0 = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(0));
|
|
|
|
float v0 = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(0));
|
|
|
|
vec.x = u0 / 16;
|
|
|
|
vec.y = v0 / 16;
|
2016-03-21 15:06:31 +00:00
|
|
|
uv.transform(vec);
|
|
|
|
float uMin = 16 * vec.x; // / vec.w;
|
|
|
|
float vMin = 16 * vec.y; // / vec.w;
|
2017-12-17 02:27:33 +00:00
|
|
|
float u1 = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(2));
|
|
|
|
float v1 = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(2));
|
|
|
|
vec.x = u1 / 16;
|
|
|
|
vec.y = v1 / 16;
|
2016-03-21 15:06:31 +00:00
|
|
|
vec.z = 0;
|
|
|
|
vec.w = 1;
|
|
|
|
uv.transform(vec);
|
|
|
|
float uMax = 16 * vec.x; // / vec.w;
|
|
|
|
float vMax = 16 * vec.y; // / vec.w;
|
2017-12-17 02:27:33 +00:00
|
|
|
if (uMin > uMax && u0 < u1 || uMin < uMax && u0 > u1)
|
2016-03-21 15:06:31 +00:00
|
|
|
{
|
|
|
|
float t = uMin;
|
|
|
|
uMin = uMax;
|
|
|
|
uMax = t;
|
|
|
|
}
|
2017-12-17 02:27:33 +00:00
|
|
|
if (vMin > vMax && v0 < v1 || vMin < vMax && v0 > v1)
|
2016-03-21 15:06:31 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2018-09-21 06:50:50 +00:00
|
|
|
public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(MainWindow res, BossInfoClient bossInfo, int x, int y, int increment)
|
2016-04-15 05:34:46 +00:00
|
|
|
{
|
|
|
|
RenderGameOverlayEvent.BossInfo evt = new RenderGameOverlayEvent.BossInfo(new RenderGameOverlayEvent(Animation.getPartialTickTime(), res),
|
|
|
|
BOSSINFO, bossInfo, x, y, increment);
|
|
|
|
MinecraftForge.EVENT_BUS.post(evt);
|
|
|
|
return evt;
|
|
|
|
}
|
|
|
|
|
2018-09-21 06:50:50 +00:00
|
|
|
public static void bossBarRenderPost(MainWindow res)
|
2016-04-15 05:34:46 +00:00
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(new RenderGameOverlayEvent(Animation.getPartialTickTime(), res), BOSSINFO));
|
|
|
|
}
|
2016-05-09 21:51:30 +00:00
|
|
|
|
2018-11-29 06:15:05 +00:00
|
|
|
public static ScreenshotEvent onScreenshot(NativeImage image, File screenshotFile)
|
2016-05-09 21:51:30 +00:00
|
|
|
{
|
|
|
|
ScreenshotEvent event = new ScreenshotEvent(image, screenshotFile);
|
|
|
|
MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2017-06-25 01:08:20 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static Pair<? extends IBakedModel,Matrix4f> handlePerspective(IBakedModel model, ItemCameraTransforms.TransformType type)
|
|
|
|
{
|
2018-09-12 01:42:29 +00:00
|
|
|
TRSRTransformation tr = TRSRTransformation.from(model.getItemCameraTransforms().getTransform(type));
|
2017-06-25 01:08:20 +00:00
|
|
|
Matrix4f mat = null;
|
2018-09-22 10:40:22 +00:00
|
|
|
if(!tr.equals(TRSRTransformation.identity())) mat = tr.getMatrixVec();
|
2017-06-25 01:08:20 +00:00
|
|
|
return Pair.of(model, mat);
|
|
|
|
}
|
2017-10-31 18:47:47 +00:00
|
|
|
|
|
|
|
public static void onInputUpdate(EntityPlayer player, MovementInput movementInput)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new InputUpdateEvent(player, movementInput));
|
|
|
|
}
|
2018-05-25 01:37:05 +00:00
|
|
|
|
2018-11-22 05:23:24 +00:00
|
|
|
public static void refreshResources(Minecraft mc, VanillaResourceType... types) {
|
|
|
|
SelectiveReloadStateHandler.INSTANCE.beginReload(ReloadRequirements.include(types));
|
|
|
|
mc.refreshResources();
|
|
|
|
SelectiveReloadStateHandler.INSTANCE.endReload();
|
2018-12-24 07:46:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiMouseClickedPre(GuiScreen guiScreen, double mouseX, double mouseY, int button)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseClickedEvent.Pre(guiScreen, mouseX, mouseY, button);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
2018-11-22 05:23:24 +00:00
|
|
|
|
2018-12-24 07:46:42 +00:00
|
|
|
public static boolean onGuiMouseClickedPost(GuiScreen guiScreen, double mouseX, double mouseY, int button)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseClickedEvent.Post(guiScreen, mouseX, mouseY, button);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiMouseReleasedPre(GuiScreen guiScreen, double mouseX, double mouseY, int button)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseReleasedEvent.Pre(guiScreen, mouseX, mouseY, button);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiMouseReleasedPost(GuiScreen guiScreen, double mouseX, double mouseY, int button)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseReleasedEvent.Post(guiScreen, mouseX, mouseY, button);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiMouseDragPre(GuiScreen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseDragEvent.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiMouseDragPost(GuiScreen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseDragEvent.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiMouseScrollPre(MouseHelper mouseHelper, GuiScreen guiScreen, double scrollDelta)
|
|
|
|
{
|
|
|
|
MainWindow mainWindow = guiScreen.mc.mainWindow;
|
|
|
|
double mouseX = mouseHelper.getMouseX() * (double) mainWindow.getScaledWidth() / (double) mainWindow.getWidth();
|
|
|
|
double mouseY = mouseHelper.getMouseY() * (double) mainWindow.getScaledHeight() / (double) mainWindow.getHeight();
|
|
|
|
Event event = new GuiScreenEvent.MouseScrollEvent.Pre(guiScreen, mouseX, mouseY, scrollDelta);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiMouseScrollPost(MouseHelper mouseHelper, GuiScreen guiScreen, double scrollDelta)
|
|
|
|
{
|
|
|
|
MainWindow mainWindow = guiScreen.mc.mainWindow;
|
|
|
|
double mouseX = mouseHelper.getMouseX() * (double) mainWindow.getScaledWidth() / (double) mainWindow.getWidth();
|
|
|
|
double mouseY = mouseHelper.getMouseY() * (double) mainWindow.getScaledHeight() / (double) mainWindow.getHeight();
|
|
|
|
Event event = new GuiScreenEvent.MouseScrollEvent.Post(guiScreen, mouseX, mouseY, scrollDelta);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiKeyPressedPre(GuiScreen guiScreen, int keyCode, int scanCode, int modifiers)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardKeyPressedEvent.Pre(guiScreen, keyCode, scanCode, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiKeyPressedPost(GuiScreen guiScreen, int keyCode, int scanCode, int modifiers)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardKeyPressedEvent.Post(guiScreen, keyCode, scanCode, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiKeyReleasedPre(GuiScreen guiScreen, int keyCode, int scanCode, int modifiers)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardKeyReleasedEvent.Pre(guiScreen, keyCode, scanCode, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiKeyReleasedPost(GuiScreen guiScreen, int keyCode, int scanCode, int modifiers)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardKeyReleasedEvent.Post(guiScreen, keyCode, scanCode, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiCharTypedPre(GuiScreen guiScreen, char codePoint, int modifiers)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardCharTypedEvent.Pre(guiScreen, codePoint, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean onGuiCharTypedPost(GuiScreen guiScreen, char codePoint, int modifiers)
|
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardCharTypedEvent.Post(guiScreen, codePoint, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
2018-11-22 05:23:24 +00:00
|
|
|
}
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|