2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2019-02-10 22:57:03 +00:00
|
|
|
* Copyright (c) 2016-2019.
|
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;
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.BOSSINFO;
|
|
|
|
import static net.minecraftforge.fml.VersionChecker.Status.BETA;
|
|
|
|
import static net.minecraftforge.fml.VersionChecker.Status.BETA_OUTDATED;
|
|
|
|
import static org.lwjgl.opengl.GL11.GL_COLOR_ARRAY;
|
|
|
|
import static org.lwjgl.opengl.GL11.GL_NORMAL_ARRAY;
|
|
|
|
import static org.lwjgl.opengl.GL11.GL_TEXTURE_COORD_ARRAY;
|
|
|
|
import static org.lwjgl.opengl.GL11.GL_VERTEX_ARRAY;
|
|
|
|
import static org.lwjgl.opengl.GL11.glColorPointer;
|
|
|
|
import static org.lwjgl.opengl.GL11.glDisableClientState;
|
|
|
|
import static org.lwjgl.opengl.GL11.glEnableClientState;
|
|
|
|
import static org.lwjgl.opengl.GL11.glMultMatrixf;
|
|
|
|
import static org.lwjgl.opengl.GL11.glNormalPointer;
|
|
|
|
import static org.lwjgl.opengl.GL11.glTexCoordPointer;
|
|
|
|
import static org.lwjgl.opengl.GL11.glVertexPointer;
|
|
|
|
import static org.lwjgl.opengl.GL20.glDisableVertexAttribArray;
|
|
|
|
import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
|
|
|
|
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.Random;
|
|
|
|
import java.util.Set;
|
2019-12-17 04:22:13 +00:00
|
|
|
import java.util.stream.Stream;
|
2019-12-11 02:27:07 +00:00
|
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2019-12-17 18:14:52 +00:00
|
|
|
import net.minecraft.client.renderer.*;
|
2019-12-11 02:27:07 +00:00
|
|
|
import net.minecraftforge.client.model.pipeline.LightUtil;
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
import org.apache.logging.log4j.core.async.ThreadNameCachingStrategy;
|
|
|
|
import org.apache.logging.log4j.core.impl.ReusableLogEventFactory;
|
|
|
|
import org.lwjgl.opengl.GL13;
|
|
|
|
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
2019-05-23 23:02:15 +00:00
|
|
|
import com.mojang.blaze3d.platform.GlStateManager;
|
2019-12-11 02:27:07 +00:00
|
|
|
import com.mojang.blaze3d.systems.RenderSystem;
|
|
|
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
|
|
|
|
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;
|
2019-09-12 15:33:19 +00:00
|
|
|
import net.minecraft.client.MouseHelper;
|
2014-04-03 10:12:22 +00:00
|
|
|
import net.minecraft.client.audio.ISound;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.client.audio.SoundEngine;
|
|
|
|
import net.minecraft.client.gui.ClientBossInfo;
|
2013-12-25 08:35:59 +00:00
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.client.gui.screen.MainMenuScreen;
|
|
|
|
import net.minecraft.client.gui.screen.Screen;
|
2019-12-11 02:27:07 +00:00
|
|
|
import net.minecraft.client.renderer.FogRenderer.FogType;
|
2019-09-12 15:33:19 +00:00
|
|
|
import net.minecraft.client.renderer.color.BlockColors;
|
|
|
|
import net.minecraft.client.renderer.color.ItemColors;
|
|
|
|
import net.minecraft.client.renderer.entity.model.BipedModel;
|
2019-02-14 23:08:53 +00:00
|
|
|
import net.minecraft.client.renderer.model.BakedQuad;
|
|
|
|
import net.minecraft.client.renderer.model.BlockFaceUV;
|
|
|
|
import net.minecraft.client.renderer.model.IBakedModel;
|
|
|
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
|
|
|
import net.minecraft.client.renderer.model.ItemTransformVec3f;
|
2019-12-11 02:27:07 +00:00
|
|
|
import net.minecraft.client.renderer.model.Material;
|
2019-02-14 23:08:53 +00:00
|
|
|
import net.minecraft.client.renderer.model.ModelManager;
|
2019-09-12 15:33:19 +00:00
|
|
|
import net.minecraft.client.renderer.texture.AtlasTexture;
|
2018-11-29 06:15:05 +00:00
|
|
|
import net.minecraft.client.renderer.texture.NativeImage;
|
2019-12-11 02:27:07 +00:00
|
|
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
2016-03-01 16:22:21 +00:00
|
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
2019-04-12 14:45:32 +00:00
|
|
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
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;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.client.renderer.vertex.VertexFormatElement.Usage;
|
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;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.entity.LivingEntity;
|
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2019-12-17 04:22:13 +00:00
|
|
|
import net.minecraft.fluid.Fluid;
|
2018-12-21 22:45:35 +00:00
|
|
|
import net.minecraft.fluid.IFluidState;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.inventory.EquipmentSlotType;
|
2012-12-13 05:58:35 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2019-09-16 21:04:32 +00:00
|
|
|
import net.minecraft.item.crafting.RecipeManager;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.util.Direction;
|
|
|
|
import net.minecraft.util.Hand;
|
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;
|
2019-12-10 19:46:01 +00:00
|
|
|
import net.minecraft.util.math.BlockRayTraceResult;
|
|
|
|
import net.minecraft.util.math.EntityRayTraceResult;
|
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.text.TextFormatting;
|
2019-12-11 02:27:07 +00:00
|
|
|
import net.minecraft.world.ILightReader;
|
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;
|
2019-09-12 15:33:19 +00:00
|
|
|
import net.minecraftforge.client.event.InputEvent;
|
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;
|
2019-09-12 15:33:19 +00:00
|
|
|
import net.minecraftforge.client.event.RecipesUpdatedEvent;
|
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;
|
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;
|
2019-12-11 02:27:07 +00:00
|
|
|
import net.minecraftforge.client.model.data.EmptyModelData;
|
2019-04-12 14:45:32 +00:00
|
|
|
import net.minecraftforge.client.model.pipeline.QuadGatheringTransformer;
|
2016-03-21 15:06:31 +00:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2019-12-11 02:27:07 +00:00
|
|
|
import net.minecraftforge.common.model.TransformationHelper;
|
2019-09-12 15:33:19 +00:00
|
|
|
import net.minecraftforge.eventbus.api.Event;
|
|
|
|
import net.minecraftforge.fml.ModLoader;
|
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;
|
2019-09-12 15:33:19 +00:00
|
|
|
import net.minecraftforge.registries.ForgeRegistries;
|
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
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EquipmentSlotType 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
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onDrawBlockHighlight(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, int subID, float partialTicks)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
2019-12-10 19:46:01 +00:00
|
|
|
switch (target.getType()) {
|
|
|
|
case BLOCK:
|
|
|
|
if (!(target instanceof BlockRayTraceResult)) return false;
|
|
|
|
return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent.HighlightBlock(context, info, target, subID, partialTicks));
|
|
|
|
case ENTITY:
|
|
|
|
if (!(target instanceof EntityRayTraceResult)) return false;
|
|
|
|
return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent.HighlightEntity(context, info, target, subID, partialTicks));
|
|
|
|
}
|
2019-05-23 23:02:15 +00:00
|
|
|
return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent(context, info, target, subID, partialTicks));
|
2012-08-23 01:02:14 +00:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
public static void dispatchRenderLast(WorldRenderer context, MatrixStack mat, float partialTicks)
|
2012-08-23 01:02:14 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(new RenderWorldLastEvent(context, mat, partialTicks));
|
2012-08-23 01:02:14 +00:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
public static boolean renderFirstPersonHand(WorldRenderer context, MatrixStack mat, float partialTicks)
|
2014-02-21 17:13:40 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(context, mat, partialTicks));
|
2014-02-21 17:13:40 +00:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
public static boolean renderSpecificFirstPersonHand(Hand hand, MatrixStack mat, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack)
|
2016-07-23 17:29:58 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
return MinecraftForge.EVENT_BUS.post(new RenderSpecificHandEvent(hand, mat, partialTicks, interpPitch, swingProgress, equipProgress, stack));
|
2016-07-23 17:29:58 +00:00
|
|
|
}
|
|
|
|
|
2019-07-03 19:26:51 +00:00
|
|
|
public static void onTextureStitchedPre(AtlasTexture map, Set<ResourceLocation> resourceLocations)
|
2013-03-18 03:07:30 +00:00
|
|
|
{
|
2019-07-03 19:26:51 +00:00
|
|
|
ModLoader.get().postEvent(new TextureStitchEvent.Pre(map, resourceLocations));
|
2018-09-12 01:42:29 +00:00
|
|
|
// ModelLoader.White.INSTANCE.register(map); // TODO Custom TAS
|
2013-03-18 03:07:30 +00:00
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static void onTextureStitchedPost(AtlasTexture map)
|
2013-03-18 03:07:30 +00:00
|
|
|
{
|
2019-06-23 00:36:07 +00:00
|
|
|
ModLoader.get().postEvent(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)
|
|
|
|
{
|
2019-06-23 00:36:07 +00:00
|
|
|
ModLoader.get().postEvent(new ColorHandlerEvent.Block(blockColors));
|
2017-12-17 01:34:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void onItemColorsInit(ItemColors itemColors, BlockColors blockColors)
|
|
|
|
{
|
2019-06-23 00:36:07 +00:00
|
|
|
ModLoader.get().postEvent(new ColorHandlerEvent.Item(itemColors, blockColors));
|
2017-12-17 01:34:00 +00:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
static final ThreadLocal<RenderType> renderLayer = new ThreadLocal<RenderType>();
|
2015-02-08 23:46:01 +00:00
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
public static void setRenderLayer(RenderType 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
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static <A extends BipedModel<?>> A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType slot, A _default)
|
2013-05-09 00:13:19 +00:00
|
|
|
{
|
2019-05-23 23:02:15 +00:00
|
|
|
A 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
|
|
|
*/
|
2019-05-23 23:02:15 +00:00
|
|
|
public static float getOffsetFOV(PlayerEntity 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
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static double getFOVModifier(GameRenderer renderer, ActiveRenderInfo info, double renderPartialTicks, double fov) {
|
|
|
|
EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, info, 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;
|
2019-10-15 21:54:47 +00:00
|
|
|
int[] ranges = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34 };
|
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);
|
2019-12-11 02:27:07 +00:00
|
|
|
Biome biome = world.func_225526_b_(pos.getX(), pos.getY(), pos.getZ());
|
|
|
|
int colour = 0xFFFFFF; // TODO: 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
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static void renderMainMenu(MainMenuScreen gui, FontRenderer font, int width, int height)
|
2013-12-25 08:35:59 +00:00
|
|
|
{
|
2019-01-27 19:51:35 +00:00
|
|
|
VersionChecker.Status status = ForgeVersion.getStatus();
|
|
|
|
if (status == BETA || status == BETA_OUTDATED)
|
2013-12-25 08:35:59 +00:00
|
|
|
{
|
|
|
|
// 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;
|
2019-01-27 19:51:35 +00:00
|
|
|
switch(status)
|
2013-12-25 08:35:59 +00:00
|
|
|
{
|
|
|
|
//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;
|
|
|
|
}
|
|
|
|
|
2019-10-05 21:02:54 +00:00
|
|
|
forgeStatusLine = line;
|
2016-05-04 01:26:52 +00:00
|
|
|
}
|
|
|
|
|
2019-10-05 21:02:54 +00:00
|
|
|
public static String forgeStatusLine;
|
2019-05-23 23:02:15 +00:00
|
|
|
public static ISound playSound(SoundEngine manager, ISound sound)
|
2014-04-03 10:12:22 +00:00
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static void drawScreen(Screen screen, int mouseX, int mouseY, float 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
|
|
|
{
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
public static float getFogDensity(FogType type, ActiveRenderInfo info, 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
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
EntityViewRenderEvent.FogDensity event = new EntityViewRenderEvent.FogDensity(type, info, 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;
|
|
|
|
}
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
public static void onFogRender(FogType type, ActiveRenderInfo info, float partial, 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
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(new EntityViewRenderEvent.RenderFogEvent(type, info, partial, 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
|
|
|
}
|
2019-12-11 02:27:07 +00:00
|
|
|
|
|
|
|
public static EntityViewRenderEvent.CameraSetup onCameraSetup(GameRenderer renderer, ActiveRenderInfo info, float partial)
|
2019-12-02 22:54:46 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
EntityViewRenderEvent.CameraSetup event = new EntityViewRenderEvent.CameraSetup(renderer, info, partial, info.getYaw(), info.getPitch(), 0);
|
2019-12-02 22:54:46 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
return event;
|
|
|
|
}
|
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
|
|
|
|
2019-06-21 23:34:58 +00:00
|
|
|
public static void onModelBake(ModelManager modelManager, Map<ResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader)
|
2014-11-27 03:56:35 +00:00
|
|
|
{
|
2019-06-23 00:36:07 +00:00
|
|
|
ModLoader.get().postEvent(new ModelBakeEvent(modelManager, modelRegistry, modelLoader));
|
2016-03-05 23:51:39 +00:00
|
|
|
modelLoader.onPostBakeEvent(modelRegistry);
|
2014-11-27 03:56:35 +00:00
|
|
|
}
|
2014-12-28 04:10:54 +00:00
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
private static final net.minecraft.client.renderer.Matrix4f flipX;
|
2019-12-17 04:46:45 +00:00
|
|
|
private static final net.minecraft.client.renderer.Matrix3f flipXNormal;
|
2016-03-10 01:48:13 +00:00
|
|
|
static {
|
2019-12-17 18:14:52 +00:00
|
|
|
flipX = Matrix4f.func_226593_a_(-1,1,1);
|
2019-12-17 04:46:45 +00:00
|
|
|
flipXNormal = new net.minecraft.client.renderer.Matrix3f(flipX);
|
2016-03-10 01:48:13 +00:00
|
|
|
}
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
public static IBakedModel handleCameraTransforms(MatrixStack matrixStack, IBakedModel model, ItemCameraTransforms.TransformType cameraTransformType, boolean leftHandHackery)
|
2014-12-28 04:10:54 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
MatrixStack stack = new MatrixStack();
|
|
|
|
model = model.handlePerspective(cameraTransformType, stack);
|
2014-12-28 04:10:54 +00:00
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
// If the stack is not empty, the code has added a matrix for us to use.
|
|
|
|
if (!stack.func_227867_d_())
|
2017-06-25 01:08:20 +00:00
|
|
|
{
|
2019-12-17 04:46:45 +00:00
|
|
|
// Apply the transformation to the real matrix stack, flipping for left hand
|
2019-12-11 02:27:07 +00:00
|
|
|
net.minecraft.client.renderer.Matrix4f tMat = stack.func_227866_c_().func_227870_a_();
|
2019-12-17 04:46:45 +00:00
|
|
|
net.minecraft.client.renderer.Matrix3f nMat = stack.func_227866_c_().func_227872_b_();
|
2017-06-25 01:08:20 +00:00
|
|
|
if (leftHandHackery)
|
2016-03-10 01:48:13 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
tMat.multiplyBackward(flipX);
|
|
|
|
tMat.func_226595_a_(flipX);
|
2019-12-17 04:46:45 +00:00
|
|
|
nMat.multiplyBackward(flipXNormal);
|
|
|
|
nMat.func_226118_b_(flipXNormal);
|
2016-03-10 01:48:13 +00:00
|
|
|
}
|
2019-12-11 02:27:07 +00:00
|
|
|
matrixStack.func_227866_c_().func_227870_a_().func_226595_a_(tMat);
|
2019-12-17 04:46:45 +00:00
|
|
|
matrixStack.func_227866_c_().func_227872_b_().func_226118_b_(nMat);
|
2014-12-28 04:10:54 +00:00
|
|
|
}
|
2019-12-11 02:27:07 +00:00
|
|
|
return model;
|
2014-12-28 04:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// moved and expanded from WorldVertexBufferUploader.draw
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static void preDraw(Usage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer)
|
2014-12-28 04:10:54 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
VertexFormatElement attr = format.func_227894_c_().get(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:
|
2019-12-11 02:27:07 +00:00
|
|
|
GL13.glClientActiveTexture(GL13.GL_TEXTURE0 + attr.getIndex());
|
2018-06-11 01:12:46 +00:00
|
|
|
glTexCoordPointer(count, constant, stride, buffer);
|
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
2019-12-11 02:27:07 +00:00
|
|
|
GL13.glClientActiveTexture(GL13.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);
|
2019-04-11 16:59:16 +00:00
|
|
|
break;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static void postDraw(Usage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer)
|
2014-12-28 04:10:54 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
VertexFormatElement attr = format.func_227894_c_().get(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
|
|
|
break;
|
|
|
|
case UV:
|
2019-12-11 02:27:07 +00:00
|
|
|
GL13.glClientActiveTexture(GL13.GL_TEXTURE0 + attr.getIndex());
|
2018-06-11 01:12:46 +00:00
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
2019-12-11 02:27:07 +00:00
|
|
|
GL13.glClientActiveTexture(GL13.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());
|
2019-04-11 16:59:16 +00:00
|
|
|
break;
|
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
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
public static int getColorIndex(VertexFormat fmt)
|
|
|
|
{
|
|
|
|
ImmutableList<VertexFormatElement> elements = fmt.func_227894_c_();
|
|
|
|
for(int i=0;i<elements.size();i++)
|
|
|
|
{
|
|
|
|
if (elements.get(i).getUsage() == Usage.COLOR)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
throw new IndexOutOfBoundsException("There is no COLOR element in the provided VertexFormat.");
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: IVertexBuilder doesn't have a means to modify existing data.
|
|
|
|
/*
|
|
|
|
public static void putQuadColor(IVertexBuilder renderer, BakedQuad quad, float cr, float cg, float cb, float ca)
|
2015-02-17 01:56:32 +00:00
|
|
|
{
|
2016-03-17 04:28:19 +00:00
|
|
|
VertexFormat format = quad.getFormat();
|
|
|
|
int size = format.getIntegerSize();
|
2019-12-11 02:27:07 +00:00
|
|
|
int offset = format.getOffset(getColorIndex(format)) / 4; // assumes that color is aligned
|
2019-04-11 20:05:19 +00:00
|
|
|
boolean hasColor = format.hasColor();
|
2015-02-17 01:56:32 +00:00
|
|
|
for(int i = 0; i < 4; i++)
|
|
|
|
{
|
2019-04-11 20:05:19 +00:00
|
|
|
int vc = hasColor ? quad.getVertexData()[offset + size * i] : 0xFFFFFFFF;
|
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
|
|
|
}
|
2019-12-11 02:27:07 +00:00
|
|
|
}*/
|
2015-09-02 04:26:42 +00:00
|
|
|
|
2019-12-17 04:22:13 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
2019-12-11 02:27:07 +00:00
|
|
|
public static TextureAtlasSprite[] getFluidSprites(ILightReader world, BlockPos pos, IFluidState fluidStateIn)
|
2019-07-28 19:35:30 +00:00
|
|
|
{
|
|
|
|
return new TextureAtlasSprite[] {
|
2019-12-17 04:22:13 +00:00
|
|
|
Minecraft.getInstance().func_228015_a_(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidStateIn.getFluid().getAttributes().getStillTexture(world, pos)),
|
|
|
|
Minecraft.getInstance().func_228015_a_(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidStateIn.getFluid().getAttributes().getFlowingTexture(world, pos)),
|
2019-07-28 19:35:30 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
public static void gatherFluidTextures(Set<Material> textures)
|
2019-09-11 14:00:32 +00:00
|
|
|
{
|
|
|
|
ForgeRegistries.FLUIDS.getValues().stream()
|
2019-12-17 04:22:13 +00:00
|
|
|
.flatMap(ForgeHooksClient::getFluidMaterials)
|
2019-09-11 14:00:32 +00:00
|
|
|
.forEach(textures::add);
|
|
|
|
}
|
|
|
|
|
2019-12-17 04:22:13 +00:00
|
|
|
public static Stream<Material> getFluidMaterials(Fluid fluid)
|
|
|
|
{
|
|
|
|
return fluid.getAttributes().getTextures()
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
.map(ForgeHooksClient::getBlockMaterial);
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static Material getBlockMaterial(ResourceLocation loc)
|
|
|
|
{
|
|
|
|
return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, loc);
|
|
|
|
}
|
|
|
|
|
2019-04-12 14:45:32 +00:00
|
|
|
private static class LightGatheringTransformer extends QuadGatheringTransformer {
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
private static final VertexFormat FORMAT = new VertexFormat(ImmutableList.of(DefaultVertexFormats.TEX_2F, DefaultVertexFormats.TEX_2S));
|
2019-04-12 14:45:32 +00:00
|
|
|
|
|
|
|
int blockLight, skyLight;
|
|
|
|
|
|
|
|
{ setVertexFormat(FORMAT); }
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
boolean hasLighting()
|
2019-04-12 14:45:32 +00:00
|
|
|
{
|
|
|
|
return dataLength[1] >= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-23 23:02:15 +00:00
|
|
|
protected void processQuad()
|
2019-04-12 14:45:32 +00:00
|
|
|
{
|
|
|
|
// Reset light data
|
|
|
|
blockLight = 0;
|
|
|
|
skyLight = 0;
|
|
|
|
// Compute average light for all 4 vertices
|
2019-05-23 23:02:15 +00:00
|
|
|
for (int i = 0; i < 4; i++)
|
2019-04-12 14:45:32 +00:00
|
|
|
{
|
|
|
|
blockLight += (int) ((quadData[1][i][0] * 0xFFFF) / 0x20);
|
|
|
|
skyLight += (int) ((quadData[1][i][1] * 0xFFFF) / 0x20);
|
|
|
|
}
|
|
|
|
// Values must be multiplied by 16, divided by 4 for average => x4
|
|
|
|
blockLight *= 4;
|
|
|
|
skyLight *= 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dummy overrides
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setQuadTint(int tint) {}
|
|
|
|
|
|
|
|
@Override
|
2019-05-23 23:02:15 +00:00
|
|
|
public void setQuadOrientation(Direction orientation) {}
|
2019-04-12 14:45:32 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setApplyDiffuseLighting(boolean diffuse) {}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setTexture(TextureAtlasSprite texture) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static final LightGatheringTransformer lightGatherer = new LightGatheringTransformer();
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
// TODO: Fix: Vanilla now batches rendering items, so our hack of forcing the GL lighting state does not work.
|
|
|
|
public static void renderLitItem(ItemRenderer ri, MatrixStack mat, IVertexBuilder consumer, IBakedModel model, ItemStack stack)
|
2019-04-12 14:45:32 +00:00
|
|
|
{
|
|
|
|
List<BakedQuad> allquads = new ArrayList<>();
|
|
|
|
Random random = new Random();
|
|
|
|
long seed = 42L;
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
for (Direction enumfacing : Direction.values())
|
2019-04-12 14:45:32 +00:00
|
|
|
{
|
|
|
|
random.setSeed(seed);
|
2019-12-11 02:27:07 +00:00
|
|
|
allquads.addAll(model.getQuads(null, enumfacing, random, EmptyModelData.INSTANCE));
|
2019-04-12 14:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
random.setSeed(seed);
|
2019-12-11 02:27:07 +00:00
|
|
|
allquads.addAll(model.getQuads(null, null, random, EmptyModelData.INSTANCE));
|
2019-04-12 14:45:32 +00:00
|
|
|
|
|
|
|
if (allquads.isEmpty()) return;
|
|
|
|
|
|
|
|
// Current list of consecutive quads with the same lighting
|
|
|
|
List<BakedQuad> segment = new ArrayList<>();
|
|
|
|
|
|
|
|
// Lighting of the current segment
|
2019-01-07 23:19:53 +00:00
|
|
|
int segmentBlockLight = 0;
|
|
|
|
int segmentSkyLight = 0;
|
2019-01-04 18:48:36 +00:00
|
|
|
// Diffuse lighting state
|
|
|
|
boolean segmentShading = true;
|
2019-01-04 02:11:34 +00:00
|
|
|
// State changed by the current segment
|
|
|
|
boolean segmentLightingDirty = false;
|
2019-01-04 18:48:36 +00:00
|
|
|
boolean segmentShadingDirty = false;
|
2019-04-12 14:45:32 +00:00
|
|
|
// If the current segment contains lighting data
|
|
|
|
boolean hasLighting = false;
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
for (int i = 0; i < allquads.size(); i++)
|
2019-04-12 14:45:32 +00:00
|
|
|
{
|
|
|
|
BakedQuad q = allquads.get(i);
|
|
|
|
|
|
|
|
// Lighting of the current quad
|
|
|
|
int bl = 0;
|
|
|
|
int sl = 0;
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
if (q.getFormat().hasUV(1))
|
2019-04-12 14:45:32 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
LightUtil.putBakedQuad(lightGatherer, q);
|
2019-04-12 14:45:32 +00:00
|
|
|
if (lightGatherer.hasLighting())
|
|
|
|
{
|
|
|
|
bl = lightGatherer.blockLight;
|
|
|
|
sl = lightGatherer.skyLight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-04 18:48:36 +00:00
|
|
|
boolean shade = q.shouldApplyDiffuseLighting();
|
|
|
|
|
2019-04-12 14:45:32 +00:00
|
|
|
boolean lightingDirty = segmentBlockLight != bl || segmentSkyLight != sl;
|
2019-05-23 23:02:15 +00:00
|
|
|
boolean shadeDirty = shade != segmentShading;
|
2019-04-12 14:45:32 +00:00
|
|
|
|
|
|
|
// If lighting or color data has changed, draw the segment and flush it
|
2019-01-07 23:19:53 +00:00
|
|
|
if (lightingDirty || shadeDirty)
|
2019-04-12 14:45:32 +00:00
|
|
|
{
|
|
|
|
if (i > 0) // Make sure this isn't the first quad being processed
|
2019-12-11 02:27:07 +00:00
|
|
|
drawSegment(ri, mat, consumer, stack, segment, segmentBlockLight, segmentSkyLight, segmentShading, segmentLightingDirty && (hasLighting || segment.size() < i), segmentShadingDirty);
|
2019-04-12 14:45:32 +00:00
|
|
|
segmentBlockLight = bl;
|
|
|
|
segmentSkyLight = sl;
|
2019-01-04 18:48:36 +00:00
|
|
|
segmentShading = shade;
|
2019-01-04 02:11:34 +00:00
|
|
|
segmentLightingDirty = lightingDirty;
|
2019-01-04 18:48:36 +00:00
|
|
|
segmentShadingDirty = shadeDirty;
|
2019-01-07 23:19:53 +00:00
|
|
|
hasLighting = segmentBlockLight > 0 || segmentSkyLight > 0 || !segmentShading;
|
2019-04-12 14:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
segment.add(q);
|
|
|
|
}
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
drawSegment(ri, mat, consumer, stack, segment, segmentBlockLight, segmentSkyLight, segmentShading, segmentLightingDirty && (hasLighting || segment.size() < allquads.size()), segmentShadingDirty);
|
2019-04-12 14:45:32 +00:00
|
|
|
|
|
|
|
// Clean up render state if necessary
|
|
|
|
if (hasLighting)
|
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
RenderSystem.glMultiTexCoord2f(GL13.GL_TEXTURE1, GlStateManager.lastBrightnessX, GlStateManager.lastBrightnessY);
|
|
|
|
RenderSystem.enableLighting();
|
2019-04-12 14:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
private static void drawSegment(ItemRenderer ir, MatrixStack mat, IVertexBuilder cons, ItemStack stack, List<BakedQuad> segment, int bl, int sl, boolean shade, boolean updateLighting, boolean updateShading)
|
2019-04-12 14:45:32 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
float lastBl = GlStateManager.lastBrightnessX;
|
|
|
|
float lastSl = GlStateManager.lastBrightnessY;
|
2019-04-12 14:45:32 +00:00
|
|
|
|
2019-01-07 23:19:53 +00:00
|
|
|
if (updateShading)
|
2019-04-12 14:45:32 +00:00
|
|
|
{
|
2019-01-07 23:19:53 +00:00
|
|
|
if (shade)
|
2019-01-04 18:48:36 +00:00
|
|
|
{
|
2019-01-07 23:19:53 +00:00
|
|
|
// (Re-)enable lighting for normal look with shading
|
2019-12-11 02:27:07 +00:00
|
|
|
RenderSystem.enableLighting();
|
2019-01-04 18:48:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-07 23:19:53 +00:00
|
|
|
// Disable lighting to simulate a lack of diffuse lighting
|
2019-12-11 02:27:07 +00:00
|
|
|
RenderSystem.disableLighting();
|
2019-04-12 14:45:32 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-23 23:02:15 +00:00
|
|
|
|
2019-01-07 23:19:53 +00:00
|
|
|
if (updateLighting)
|
|
|
|
{
|
|
|
|
// Force lightmap coords to simulate synthetic lighting
|
2019-12-11 02:27:07 +00:00
|
|
|
RenderSystem.glMultiTexCoord2f(GL13.GL_TEXTURE1, Math.max(bl, lastBl), Math.max(sl, lastSl));
|
2019-01-07 23:19:53 +00:00
|
|
|
}
|
2019-04-12 14:45:32 +00:00
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
// TODO can we just use this light value ??
|
|
|
|
ir.func_229112_a_(mat, cons, segment, stack, (bl << 16) | sl, OverlayTexture.field_229196_a_);
|
2019-04-12 14:45:32 +00:00
|
|
|
|
|
|
|
// Preserve this as it represents the "world" lighting
|
2019-12-11 02:27:07 +00:00
|
|
|
GlStateManager.lastBrightnessX = lastBl;
|
|
|
|
GlStateManager.lastBrightnessY = lastSl;
|
2019-04-12 14:45:32 +00:00
|
|
|
|
|
|
|
segment.clear();
|
|
|
|
}
|
|
|
|
|
2015-10-27 21:29:16 +00:00
|
|
|
/**
|
|
|
|
* internal, relies on fixed format of FaceBakery
|
|
|
|
*/
|
2019-05-23 23:02:15 +00:00
|
|
|
public static void fillNormal(int[] faceData, Direction facing)
|
2015-06-28 22:19:10 +00:00
|
|
|
{
|
2017-09-06 21:31:46 +00:00
|
|
|
Vector3f v1 = getVertexPos(faceData, 3);
|
2019-12-17 18:14:52 +00:00
|
|
|
Vector3f t1 = getVertexPos(faceData, 1);
|
2017-09-06 21:31:46 +00:00
|
|
|
Vector3f v2 = getVertexPos(faceData, 2);
|
2019-12-17 18:14:52 +00:00
|
|
|
Vector3f t2 = getVertexPos(faceData, 0);
|
|
|
|
v1.sub(t1);
|
|
|
|
v2.sub(t2);
|
|
|
|
v2.cross(v1);
|
|
|
|
v2.func_229194_d_();
|
2015-10-27 21:29:16 +00:00
|
|
|
|
2019-12-17 18:14:52 +00:00
|
|
|
int x = ((byte) Math.round(v2.getX() * 127)) & 0xFF;
|
|
|
|
int y = ((byte) Math.round(v2.getY() * 127)) & 0xFF;
|
|
|
|
int z = ((byte) Math.round(v2.getZ() * 127)) & 0xFF;
|
2017-09-06 21:31:46 +00:00
|
|
|
|
|
|
|
int normal = x | (y << 0x08) | (z << 0x10);
|
|
|
|
|
2015-06-28 22:19:10 +00:00
|
|
|
for(int i = 0; i < 4; i++)
|
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
faceData[i * 8 + 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)
|
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
int idx = vertex * 8;
|
2017-09-06 21:31:46 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-02-14 23:08:53 +00:00
|
|
|
public static void loadEntityShader(Entity entity, GameRenderer 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-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
|
|
|
|
2019-12-11 02:27:07 +00:00
|
|
|
public static BlockFaceUV applyUVLock(BlockFaceUV blockFaceUV, Direction originalSide, TransformationMatrix rotation, ResourceLocation p_228824_9_)
|
2016-03-21 15:06:31 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
TransformationMatrix global = new TransformationMatrix(rotation.func_227988_c_());
|
2019-12-17 18:14:52 +00:00
|
|
|
Matrix4f uv = TransformationHelper.getUVLockTransform(global, originalSide).func_227988_c_();
|
2017-12-17 02:27:33 +00:00
|
|
|
float u0 = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(0));
|
|
|
|
float v0 = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(0));
|
2019-12-17 18:14:52 +00:00
|
|
|
Vector4f vec = new Vector4f(u0 / 16, v0 / 16, 0, 1);
|
|
|
|
vec.func_229372_a_(uv);
|
|
|
|
float uMin = 16 * vec.getX(); // / vec.w;
|
|
|
|
float vMin = 16 * vec.getY(); // / vec.w;
|
2017-12-17 02:27:33 +00:00
|
|
|
float u1 = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(2));
|
|
|
|
float v1 = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(2));
|
2019-12-17 18:14:52 +00:00
|
|
|
vec.set(u1 / 16,v1 / 16,0,1);
|
|
|
|
vec.func_229372_a_(uv);
|
|
|
|
float uMax = 16 * vec.getX(); // / vec.w;
|
|
|
|
float vMax = 16 * vec.getY(); // / 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);
|
2019-12-17 18:14:52 +00:00
|
|
|
Matrix3f rot = new Matrix3f(uv);
|
|
|
|
rv.func_229188_a_(rot);
|
|
|
|
int angle = MathHelper.normalizeAngle(-(int)Math.round(Math.toDegrees(Math.atan2(rv.getY(), rv.getX())) / 90) * 90, 360);
|
2016-03-21 15:06:31 +00:00
|
|
|
return new BlockFaceUV(new float[]{ uMin, vMin, uMax, vMax }, angle);
|
|
|
|
}
|
2016-04-15 05:34:46 +00:00
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(MainWindow res, ClientBossInfo 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")
|
2019-12-11 02:27:07 +00:00
|
|
|
public static IBakedModel handlePerspective(IBakedModel model, ItemCameraTransforms.TransformType type, MatrixStack stack)
|
2017-06-25 01:08:20 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
if (!model.getItemCameraTransforms().getTransform(type).equals(ItemTransformVec3f.DEFAULT))
|
|
|
|
{
|
|
|
|
// Push to the matrix to make it not empty and indicate that we want to transform things
|
|
|
|
stack.func_227860_a_();
|
|
|
|
model.getItemCameraTransforms().getTransform(type).func_228830_a_(false, stack);
|
|
|
|
}
|
|
|
|
return model;
|
2017-06-25 01:08:20 +00:00
|
|
|
}
|
2017-10-31 18:47:47 +00:00
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static void onInputUpdate(PlayerEntity player, MovementInput movementInput)
|
2017-10-31 18:47:47 +00:00
|
|
|
{
|
|
|
|
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));
|
2019-07-19 15:55:30 +00:00
|
|
|
mc.reloadResources();
|
2018-11-22 05:23:24 +00:00
|
|
|
SelectiveReloadStateHandler.INSTANCE.endReload();
|
2018-12-24 07:46:42 +00:00
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiMouseClickedPre(Screen guiScreen, double mouseX, double mouseY, int button)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseClickedEvent.Pre(guiScreen, mouseX, mouseY, button);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
2018-11-22 05:23:24 +00:00
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiMouseClickedPost(Screen guiScreen, double mouseX, double mouseY, int button)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseClickedEvent.Post(guiScreen, mouseX, mouseY, button);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiMouseReleasedPre(Screen guiScreen, double mouseX, double mouseY, int button)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseReleasedEvent.Pre(guiScreen, mouseX, mouseY, button);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiMouseReleasedPost(Screen guiScreen, double mouseX, double mouseY, int button)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseReleasedEvent.Post(guiScreen, mouseX, mouseY, button);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiMouseDragPre(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseDragEvent.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.MouseDragEvent.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiMouseScrollPre(MouseHelper mouseHelper, Screen guiScreen, double scrollDelta)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
MainWindow mainWindow = guiScreen.getMinecraft().func_228018_at_();
|
2018-12-24 07:46:42 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiMouseScrollPost(MouseHelper mouseHelper, Screen guiScreen, double scrollDelta)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
2019-12-11 02:27:07 +00:00
|
|
|
MainWindow mainWindow = guiScreen.getMinecraft().func_228018_at_();
|
2018-12-24 07:46:42 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiKeyPressedPre(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardKeyPressedEvent.Pre(guiScreen, keyCode, scanCode, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiKeyPressedPost(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardKeyPressedEvent.Post(guiScreen, keyCode, scanCode, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiKeyReleasedPre(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardKeyReleasedEvent.Pre(guiScreen, keyCode, scanCode, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiKeyReleasedPost(Screen guiScreen, int keyCode, int scanCode, int modifiers)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardKeyReleasedEvent.Post(guiScreen, keyCode, scanCode, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiCharTypedPre(Screen guiScreen, char codePoint, int modifiers)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardCharTypedEvent.Pre(guiScreen, codePoint, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static boolean onGuiCharTypedPost(Screen guiScreen, char codePoint, int modifiers)
|
2018-12-24 07:46:42 +00:00
|
|
|
{
|
|
|
|
Event event = new GuiScreenEvent.KeyboardCharTypedEvent.Post(guiScreen, codePoint, modifiers);
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
2018-11-22 05:23:24 +00:00
|
|
|
}
|
2019-01-25 21:36:42 +00:00
|
|
|
|
2019-09-16 21:04:32 +00:00
|
|
|
public static void onRecipesUpdated(RecipeManager mgr)
|
2019-01-25 21:36:42 +00:00
|
|
|
{
|
2019-09-16 21:04:32 +00:00
|
|
|
Event event = new RecipesUpdatedEvent(mgr);
|
2019-01-25 21:36:42 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
2019-04-12 14:23:08 +00:00
|
|
|
|
|
|
|
// Resets cached thread fields in ThreadNameCachingStrategy and ReusableLogEventFactory to be repopulated during their next access.
|
|
|
|
// This serves a workaround for no built-in method of triggering this type of refresh as brought up by LOG4J2-2178.
|
|
|
|
public static void invalidateLog4jThreadCache()
|
|
|
|
{
|
2019-06-08 18:38:18 +00:00
|
|
|
if (System.getProperty("java.version").compareTo("1.8.0_102") >= 0) return; // skip for later JDKs, because it's not CACHED see LOG4J2-2052
|
2019-04-12 14:23:08 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Field nameField = ThreadNameCachingStrategy.class.getDeclaredField("THREADLOCAL_NAME");
|
|
|
|
Field logEventField = ReusableLogEventFactory.class.getDeclaredField("mutableLogEventThreadLocal");
|
|
|
|
nameField.setAccessible(true);
|
|
|
|
logEventField.setAccessible(true);
|
|
|
|
((ThreadLocal<?>) nameField.get(null)).set(null);
|
|
|
|
((ThreadLocal<?>) logEventField.get(null)).set(null);
|
|
|
|
}
|
|
|
|
catch (ReflectiveOperationException | NoClassDefFoundError e)
|
|
|
|
{
|
|
|
|
LOGGER.error("Unable to invalidate log4j thread cache, thread fields in logs may be inaccurate", e);
|
|
|
|
}
|
|
|
|
}
|
2019-04-16 01:50:18 +00:00
|
|
|
|
|
|
|
public static void fireMouseInput(int button, int action, int mods)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new InputEvent.MouseInputEvent(button, action, mods));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void fireKeyInput(int key, int scanCode, int action, int modifiers)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new InputEvent.KeyInputEvent(key, scanCode, action, modifiers));
|
|
|
|
}
|
2019-08-29 04:13:31 +00:00
|
|
|
|
|
|
|
public static boolean onMouseScroll(MouseHelper mouseHelper, double scrollDelta)
|
|
|
|
{
|
|
|
|
Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.isLeftDown(), mouseHelper.isMiddleDown(), mouseHelper.isRightDown(), mouseHelper.getMouseX(), mouseHelper.getMouseY());
|
|
|
|
return MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
}
|
2019-09-16 20:03:10 +00:00
|
|
|
|
|
|
|
public static boolean onRawMouseClicked(int button, int action, int mods)
|
|
|
|
{
|
|
|
|
return MinecraftForge.EVENT_BUS.post(new InputEvent.RawMouseEvent(button, action, mods));
|
|
|
|
}
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|