2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2020-07-02 17:49:11 +00:00
|
|
|
* Copyright (c) 2016-2020.
|
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 com.google.common.collect.ImmutableList;
|
|
|
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
|
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
2020-11-21 19:57:33 +00:00
|
|
|
import net.minecraft.block.BlockState;
|
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;
|
2020-09-10 19:01:34 +00:00
|
|
|
import net.minecraft.client.gui.AbstractGui;
|
2019-05-23 23:02:15 +00:00
|
|
|
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;
|
2020-10-15 17:15:06 +00:00
|
|
|
import net.minecraft.client.network.play.NetworkPlayerInfo;
|
2020-07-03 03:54:46 +00:00
|
|
|
import net.minecraft.client.renderer.*;
|
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;
|
2020-07-03 03:54:46 +00:00
|
|
|
import net.minecraft.client.renderer.model.IBakedModel;
|
|
|
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
|
|
|
import net.minecraft.client.renderer.model.ModelManager;
|
|
|
|
import net.minecraft.client.renderer.model.RenderMaterial;
|
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;
|
2016-03-01 16:22:21 +00:00
|
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
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;
|
2020-07-03 03:54:46 +00:00
|
|
|
import net.minecraft.client.settings.KeyBinding;
|
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;
|
2020-10-26 23:52:36 +00:00
|
|
|
import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2019-12-17 04:22:13 +00:00
|
|
|
import net.minecraft.fluid.Fluid;
|
2020-07-03 03:54:46 +00:00
|
|
|
import net.minecraft.fluid.FluidState;
|
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-01 12:58:03 +00:00
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
2020-07-03 03:54:46 +00:00
|
|
|
import net.minecraft.util.math.vector.Matrix3f;
|
|
|
|
import net.minecraft.util.math.vector.Matrix4f;
|
|
|
|
import net.minecraft.util.math.vector.TransformationMatrix;
|
|
|
|
import net.minecraft.util.math.vector.Vector3f;
|
|
|
|
import net.minecraft.util.text.ITextComponent;
|
2016-03-01 12:58:03 +00:00
|
|
|
import net.minecraft.util.text.TextFormatting;
|
2020-07-03 03:54:46 +00:00
|
|
|
import net.minecraft.util.text.TranslationTextComponent;
|
2020-10-15 17:15:06 +00:00
|
|
|
import net.minecraft.world.GameType;
|
2020-07-03 03:54:46 +00:00
|
|
|
import net.minecraft.world.IBlockDisplayReader;
|
2020-11-21 19:57:33 +00:00
|
|
|
import net.minecraft.world.World;
|
2020-07-03 03:54:46 +00:00
|
|
|
import net.minecraftforge.client.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
|
|
|
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;
|
2020-10-26 23:52:36 +00:00
|
|
|
import net.minecraftforge.common.ForgeMod;
|
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;
|
2020-07-03 03:54:46 +00:00
|
|
|
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
|
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;
|
2020-07-03 03:54:46 +00:00
|
|
|
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 javax.annotation.Nonnull;
|
|
|
|
import java.io.File;
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.nio.Buffer;
|
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Objects;
|
2020-11-21 19:57:33 +00:00
|
|
|
import java.util.Random;
|
2020-07-03 03:54:46 +00:00
|
|
|
import java.util.Set;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
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.*;
|
|
|
|
import static org.lwjgl.opengl.GL20.*;
|
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
|
|
|
|
2020-09-08 19:50:06 +00:00
|
|
|
//TODO: Rename to onDrawHighlight
|
2020-01-29 23:46:22 +00:00
|
|
|
public static boolean onDrawBlockHighlight(WorldRenderer context, ActiveRenderInfo info, RayTraceResult target, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffers)
|
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;
|
2020-01-29 23:46:22 +00:00
|
|
|
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightBlock(context, info, target, partialTicks, matrix, buffers));
|
2019-12-10 19:46:01 +00:00
|
|
|
case ENTITY:
|
|
|
|
if (!(target instanceof EntityRayTraceResult)) return false;
|
2020-01-29 23:46:22 +00:00
|
|
|
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent.HighlightEntity(context, info, target, partialTicks, matrix, buffers));
|
2020-09-10 19:01:34 +00:00
|
|
|
default:
|
|
|
|
return MinecraftForge.EVENT_BUS.post(new DrawHighlightEvent(context, info, target, partialTicks, matrix, buffers));
|
2019-12-10 19:46:01 +00:00
|
|
|
}
|
2012-08-23 01:02:14 +00:00
|
|
|
}
|
|
|
|
|
2020-03-11 07:00:21 +00:00
|
|
|
public static void dispatchRenderLast(WorldRenderer context, MatrixStack mat, float partialTicks, Matrix4f projectionMatrix, long finishTimeNano)
|
|
|
|
{
|
|
|
|
MinecraftForge.EVENT_BUS.post(new RenderWorldLastEvent(context, mat, partialTicks, projectionMatrix, finishTimeNano));
|
|
|
|
}
|
|
|
|
|
2020-01-29 23:46:22 +00:00
|
|
|
public static boolean renderSpecificFirstPersonHand(Hand hand, MatrixStack mat, IRenderTypeBuffer buffers, int light, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack)
|
2016-07-23 17:29:58 +00:00
|
|
|
{
|
2020-01-29 23:46:22 +00:00
|
|
|
return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(hand, mat, buffers, light, 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
|
|
|
{
|
2020-03-20 21:34:42 +00:00
|
|
|
StartupMessageManager.mcLoaderConsumer().ifPresent(c->c.accept("Atlas Stitching : "+map.getTextureLocation().toString()));
|
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-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
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
public static void renderMainMenu(MainMenuScreen gui, MatrixStack mStack, 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,
|
2020-10-29 00:11:57 +00:00
|
|
|
ITextComponent line = new TranslationTextComponent("forge.update.beta.1", TextFormatting.RED, TextFormatting.RESET).mergeStyle(TextFormatting.RED);
|
|
|
|
AbstractGui.drawCenteredString(mStack, font, line, width / 2, 4 + (0 * (font.FONT_HEIGHT + 1)), -1);
|
2020-06-19 14:58:45 +00:00
|
|
|
line = new TranslationTextComponent("forge.update.beta.2");
|
2020-10-29 00:11:57 +00:00
|
|
|
AbstractGui.drawCenteredString(mStack, font, line, width / 2, 4 + (1 * (font.FONT_HEIGHT + 1)), -1);
|
2013-12-25 08:35:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
public static void drawScreen(Screen screen, MatrixStack mStack, 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
|
|
|
{
|
2020-06-19 14:58:45 +00:00
|
|
|
if (!MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Pre(screen, mStack, mouseX, mouseY, partialTicks)))
|
2020-10-29 00:11:57 +00:00
|
|
|
screen.render(mStack, mouseX, mouseY, partialTicks);
|
2020-06-19 14:58:45 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(screen, mStack, 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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
private static final Matrix4f flipX;
|
|
|
|
private static final Matrix3f flipXNormal;
|
2016-03-10 01:48:13 +00:00
|
|
|
static {
|
2020-02-26 03:45:14 +00:00
|
|
|
flipX = Matrix4f.makeScale(-1,1,1);
|
2020-06-19 14:58:45 +00:00
|
|
|
flipXNormal = new 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.
|
2020-02-26 03:45:14 +00:00
|
|
|
if (!stack.clear())
|
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
|
2020-06-19 14:58:45 +00:00
|
|
|
Matrix4f tMat = stack.getLast().getMatrix();
|
|
|
|
Matrix3f nMat = stack.getLast().getNormal();
|
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);
|
2020-02-26 03:45:14 +00:00
|
|
|
tMat.mul(flipX);
|
2019-12-17 04:46:45 +00:00
|
|
|
nMat.multiplyBackward(flipXNormal);
|
2020-02-26 03:45:14 +00:00
|
|
|
nMat.mul(flipXNormal);
|
2016-03-10 01:48:13 +00:00
|
|
|
}
|
2020-02-26 03:45:14 +00:00
|
|
|
matrixStack.getLast().getMatrix().mul(tMat);
|
|
|
|
matrixStack.getLast().getNormal().mul(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
|
|
|
{
|
2020-02-26 03:45:14 +00:00
|
|
|
VertexFormatElement attr = format.getElements().get(element);
|
2016-01-01 15:15:48 +00:00
|
|
|
int count = attr.getElementCount();
|
|
|
|
int constant = attr.getType().getGlConstant();
|
2020-04-15 06:54:32 +00:00
|
|
|
((Buffer)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
|
|
|
{
|
2020-02-26 03:45:14 +00:00
|
|
|
VertexFormatElement attr = format.getElements().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)
|
|
|
|
{
|
2020-02-26 03:45:14 +00:00
|
|
|
ImmutableList<VertexFormatElement> elements = fmt.getElements();
|
2019-12-11 02:27:07 +00:00
|
|
|
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")
|
2020-06-19 14:58:45 +00:00
|
|
|
public static TextureAtlasSprite[] getFluidSprites(IBlockDisplayReader world, BlockPos pos, FluidState fluidStateIn)
|
2019-07-28 19:35:30 +00:00
|
|
|
{
|
2019-12-19 16:51:07 +00:00
|
|
|
ResourceLocation overlayTexture = fluidStateIn.getFluid().getAttributes().getOverlayTexture();
|
2019-07-28 19:35:30 +00:00
|
|
|
return new TextureAtlasSprite[] {
|
2020-02-26 03:45:14 +00:00
|
|
|
Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidStateIn.getFluid().getAttributes().getStillTexture(world, pos)),
|
|
|
|
Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidStateIn.getFluid().getAttributes().getFlowingTexture(world, pos)),
|
|
|
|
overlayTexture == null ? null : Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(overlayTexture),
|
2019-07-28 19:35:30 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
public static void gatherFluidTextures(Set<RenderMaterial> 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);
|
|
|
|
}
|
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
public static Stream<RenderMaterial> getFluidMaterials(Fluid fluid)
|
2019-12-17 04:22:13 +00:00
|
|
|
{
|
|
|
|
return fluid.getAttributes().getTextures()
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
.map(ForgeHooksClient::getBlockMaterial);
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
2020-06-19 14:58:45 +00:00
|
|
|
public static RenderMaterial getBlockMaterial(ResourceLocation loc)
|
2019-12-17 04:22:13 +00:00
|
|
|
{
|
2020-06-19 14:58:45 +00:00
|
|
|
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, loc);
|
2019-12-17 04:22:13 +00:00
|
|
|
}
|
|
|
|
|
2015-10-27 21:29:16 +00:00
|
|
|
/**
|
|
|
|
* internal, relies on fixed format of FaceBakery
|
|
|
|
*/
|
2019-12-17 22:37:39 +00:00
|
|
|
// TODO Do we need this?
|
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);
|
2020-02-26 03:45:14 +00:00
|
|
|
v2.normalize();
|
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-30 21:12:14 +00:00
|
|
|
faceData[i * 8 + 7] = 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
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(MatrixStack mStack, MainWindow res, ClientBossInfo bossInfo, int x, int y, int increment)
|
2016-04-15 05:34:46 +00:00
|
|
|
{
|
2020-06-19 14:58:45 +00:00
|
|
|
RenderGameOverlayEvent.BossInfo evt = new RenderGameOverlayEvent.BossInfo(mStack, new RenderGameOverlayEvent(mStack, Animation.getPartialTickTime(), res),
|
2016-04-15 05:34:46 +00:00
|
|
|
BOSSINFO, bossInfo, x, y, increment);
|
|
|
|
MinecraftForge.EVENT_BUS.post(evt);
|
|
|
|
return evt;
|
|
|
|
}
|
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
public static void bossBarRenderPost(MatrixStack mStack, MainWindow res)
|
2016-04-15 05:34:46 +00:00
|
|
|
{
|
2020-06-19 14:58:45 +00:00
|
|
|
MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(mStack, new RenderGameOverlayEvent(mStack, Animation.getPartialTickTime(), res), BOSSINFO));
|
2016-04-15 05:34:46 +00:00
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2020-10-15 17:15:06 +00:00
|
|
|
public static void onClientChangeGameMode(NetworkPlayerInfo info, GameType currentGameMode, GameType newGameMode)
|
|
|
|
{
|
|
|
|
if (currentGameMode != newGameMode)
|
|
|
|
{
|
|
|
|
ClientPlayerChangeGameModeEvent evt = new ClientPlayerChangeGameModeEvent(info, currentGameMode, newGameMode);
|
|
|
|
MinecraftForge.EVENT_BUS.post(evt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-17 23:45:06 +00:00
|
|
|
TransformationMatrix tr = TransformationHelper.toTransformation(model.getItemCameraTransforms().getTransform(type));
|
|
|
|
if(!tr.isIdentity()) {
|
|
|
|
tr.push(stack);
|
2019-12-11 02:27:07 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2020-02-26 03:45:14 +00:00
|
|
|
MainWindow mainWindow = guiScreen.getMinecraft().getMainWindow();
|
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
|
|
|
{
|
2020-02-26 03:45:14 +00:00
|
|
|
MainWindow mainWindow = guiScreen.getMinecraft().getMainWindow();
|
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));
|
|
|
|
}
|
2020-01-16 00:30:01 +00:00
|
|
|
|
|
|
|
public static InputEvent.ClickInputEvent onClickInput(int button, KeyBinding keyBinding, Hand hand)
|
|
|
|
{
|
|
|
|
InputEvent.ClickInputEvent event = new InputEvent.ClickInputEvent(button, keyBinding, hand);
|
|
|
|
MinecraftForge.EVENT_BUS.post(event);
|
|
|
|
return event;
|
|
|
|
}
|
2020-07-02 15:05:20 +00:00
|
|
|
|
2020-07-03 03:54:46 +00:00
|
|
|
public static void drawItemLayered(ItemRenderer renderer, IBakedModel modelIn, ItemStack itemStackIn, MatrixStack matrixStackIn,
|
|
|
|
IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn, boolean fabulous)
|
2020-07-02 15:05:20 +00:00
|
|
|
{
|
2020-07-03 03:54:46 +00:00
|
|
|
for(com.mojang.datafixers.util.Pair<IBakedModel,RenderType> layerModel : modelIn.getLayerModels(itemStackIn, fabulous))
|
|
|
|
{
|
|
|
|
IBakedModel layer = layerModel.getFirst();
|
2020-07-02 15:05:20 +00:00
|
|
|
RenderType rendertype = layerModel.getSecond();
|
|
|
|
net.minecraftforge.client.ForgeHooksClient.setRenderLayer(rendertype); // neded for compatibility with MultiLayerModels
|
2020-07-03 03:54:46 +00:00
|
|
|
IVertexBuilder ivertexbuilder;
|
|
|
|
if (fabulous)
|
|
|
|
{
|
2020-10-29 00:11:57 +00:00
|
|
|
ivertexbuilder = ItemRenderer.getEntityGlintVertexBuilder(bufferIn, rendertype, true, itemStackIn.hasEffect());
|
2020-07-03 03:54:46 +00:00
|
|
|
} else {
|
|
|
|
ivertexbuilder = ItemRenderer.getBuffer(bufferIn, rendertype, true, itemStackIn.hasEffect());
|
|
|
|
}
|
|
|
|
renderer.renderModel(layer, itemStackIn, combinedLightIn, combinedOverlayIn, matrixStackIn, ivertexbuilder);
|
2020-07-02 15:05:20 +00:00
|
|
|
}
|
|
|
|
net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null);
|
|
|
|
}
|
2020-10-26 23:52:36 +00:00
|
|
|
|
|
|
|
public static boolean isNameplateInRenderDistance(Entity entity, double squareDistance) {
|
|
|
|
if (entity instanceof LivingEntity) {
|
|
|
|
final ModifiableAttributeInstance attribute = ((LivingEntity) entity).getAttribute(ForgeMod.NAMETAG_DISTANCE.get());
|
|
|
|
if (attribute != null) {
|
|
|
|
return !(squareDistance > (attribute.getValue() * attribute.getValue()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return !(squareDistance > 4096.0f);
|
|
|
|
}
|
2020-11-21 19:57:33 +00:00
|
|
|
|
|
|
|
public static void renderPistonMovedBlocks(BlockPos pos, BlockState state, MatrixStack stack, IRenderTypeBuffer buffer, World world, boolean checkSides, int combinedOverlay, BlockRendererDispatcher blockRenderer) {
|
|
|
|
RenderType.getBlockRenderTypes().stream()
|
|
|
|
.filter(t -> RenderTypeLookup.canRenderInLayer(state, t))
|
|
|
|
.forEach(rendertype ->
|
|
|
|
{
|
|
|
|
rendertype = rendertype == RenderType.getTranslucent() ? RenderType.getTranslucentMovingBlock() : rendertype;
|
|
|
|
setRenderLayer(rendertype);
|
|
|
|
IVertexBuilder ivertexbuilder = buffer.getBuffer(rendertype);
|
|
|
|
blockRenderer.getBlockModelRenderer().renderModel(world, blockRenderer.getModelForState(state), state, pos, stack, ivertexbuilder, checkSides, new Random(), state.getPositionRandom(pos), combinedOverlay);
|
|
|
|
});
|
|
|
|
setRenderLayer(null);
|
|
|
|
}
|
2012-08-06 10:35:57 +00:00
|
|
|
}
|