Rendering patches (#5262)

This commit is contained in:
tterrag authored and LexManos committed 2018-12-21 14:45:35 -08:00
1 parent 0bfa76251d
commit b3b8c78527
122 files changed
+2354 -2888

No files matched your search

@@ -24,11 +24,21 @@ import java.util.function.Predicate;
import javax.annotation.Nullable;
import net.minecraft.block.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBed;
import net.minecraft.block.BlockFarmland;
import net.minecraft.block.BlockFence;
import net.minecraft.block.BlockFire;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.BlockStainedGlass;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
@@ -51,8 +61,12 @@ import net.minecraft.state.IProperty;
import net.minecraft.state.properties.BedPart;
import net.minecraft.tags.BlockTags;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
@@ -67,7 +81,6 @@ import net.minecraft.world.WorldServer;
import net.minecraft.world.dimension.EndDimension;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.ToolType;
@@ -260,7 +273,7 @@ public interface IForgeBlock
* @param player The player or camera entity, null in some cases.
* @return True to treat this as a bed
*/
default boolean isBed(IBlockState state, IBlockReader world, BlockPos pos, @Nullable EntityPlayer player)
default boolean isBed(IBlockState state, IBlockReader world, BlockPos pos, @Nullable Entity player)
{
return this.getBlock() instanceof BlockBed; //TODO: Forge: Keep isBed function?
}
@@ -780,7 +793,7 @@ public interface IForgeBlock
/**
* Queries if this block should render in a given layer.
* ISmartBlockModel can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderLayer()} to alter their model based on layer.
* A custom {@link IBakedModel} can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderLayer()} to alter the model based on layer.
*/
default boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer)
{
@@ -861,7 +874,7 @@ public interface IForgeBlock
* @param viewpoint the viewpoint
* @return the block state that should be 'seen'
*/
default IBlockState getStateAtViewpoint(IBlockState state, IWorldReader world, BlockPos pos, Vec3d viewpoint)
default IBlockState getStateAtViewpoint(IBlockState state, IBlockReader world, BlockPos pos, Vec3d viewpoint)
{
return state;
}
@@ -26,6 +26,7 @@ import javax.annotation.Nullable;
import net.minecraft.block.*;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
@@ -680,8 +681,8 @@ public interface IForgeBlockState
}
/**
* Queries if this block should render in a given layer.
* ISmartBlockModel can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderLayer()} to alter their model based on layer.
* Queries if this blockstate should render in a given layer.
* A custom {@link IBakedModel} can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderLayer()} to alter the model based on layer.
*/
default boolean canRenderInLayer(BlockRenderLayer layer)
{
@@ -111,6 +111,20 @@ public interface IForgeDimension
@OnlyIn(Dist.CLIENT)
void setWeatherRenderer(IRenderHandler renderer);
/**
* Allows for manipulating the coloring of the lightmap texture.
* Will be called for each 16*16 combination of sky/block light values.
*
* @param partialTicks Progress between ticks.
* @param sunBrightness Current sun brightness.
* @param skyLight Sky light brightness factor.
* @param blockLight Block light brightness factor.
* @param colors The color values that will be used: [r, g, b].
*
* @see net.minecraft.client.renderer.EntityRenderer#updateLightmap(float)
*/
default void getLightmapColors(float partialTicks, float sunBrightness, float skyLight, float blockLight, float[] colors) {}
void resetRainAndThunder();
@@ -22,11 +22,12 @@ package net.minecraftforge.common.extensions;
import javax.annotation.Nullable;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.entity.Entity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.IFluidState;
import net.minecraft.tags.Tag;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
@@ -98,4 +99,13 @@ public interface IForgeFluid
{
return state.getExplosionResistance();
}
/**
* Queries if this fluid should render in a given layer.
* A custom {@link IBakedModel} can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderLayer()} to alter the model based on layer.
*/
default boolean canRenderInLayer(IFluidState state, BlockRenderLayer layer)
{
return this.getFluid().getRenderLayer() == layer;
}
}
@@ -21,10 +21,12 @@ package net.minecraftforge.common.extensions;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.entity.Entity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.IFluidState;
import net.minecraft.tags.Tag;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
import net.minecraft.world.IWorldReader;
@@ -67,4 +69,13 @@ public interface IForgeFluidState
{
return getFluidState().getFluid().getExplosionResistance(getFluidState(), world, pos, exploder, explosion);
}
/**
* Queries if this fluidstate should render in a given layer.
* A custom {@link IBakedModel} can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderLayer()} to alter the model based on layer.
*/
default boolean canRenderInLayer(BlockRenderLayer layer)
{
return getFluidState().getFluid().canRenderInLayer(getFluidState(), layer);
}
}
@@ -19,8 +19,16 @@
package net.minecraftforge.common.extensions;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound>
@@ -78,5 +86,86 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
* Called when this is first added to the world (by {@link World#addTileEntity(TileEntity)}).
* Override instead of adding {@code if (firstTick)} stuff in update.
*/
default void onLoad(){}
default void onLoad(){}
default boolean shouldRenderInPass(int pass)
{
return pass == 0;
}
/**
* Sometimes default render bounding box: infinite in scope. Used to control rendering on {@link TileEntitySpecialRenderer}.
*/
public static final AxisAlignedBB INFINITE_EXTENT_AABB = new net.minecraft.util.math.AxisAlignedBB(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
/**
* Return an {@link AxisAlignedBB} that controls the visible scope of a {@link TileEntitySpecialRenderer} associated with this {@link TileEntity}
* Defaults to the collision bounding box {@link Block#getCollisionBoundingBoxFromPool(World, int, int, int)} associated with the block
* at this location.
*
* @return an appropriately size {@link AxisAlignedBB} for the {@link TileEntity}
*/
@OnlyIn(Dist.CLIENT)
default AxisAlignedBB getRenderBoundingBox()
{
AxisAlignedBB bb = INFINITE_EXTENT_AABB;
IBlockState state = getTileEntity().getBlockState();
Block block = state.getBlock();
BlockPos pos = getTileEntity().getPos();
if (block == Blocks.ENCHANTING_TABLE)
{
bb = new AxisAlignedBB(pos, pos.add(1, 1, 1));
}
else if (block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST)
{
bb = new AxisAlignedBB(pos.add(-1, 0, -1), pos.add(2, 2, 2));
}
else if (block == Blocks.STRUCTURE_BLOCK)
{
bb = INFINITE_EXTENT_AABB;
}
else if (block != null && block != Blocks.BEACON)
{
AxisAlignedBB cbb = null;
try
{
cbb = state.getCollisionShape(getTileEntity().getWorld(), pos).getBoundingBox().offset(pos);
}
catch (Exception e)
{
// We have to capture any exceptions that may occur here because BUKKIT servers like to send
// the tile entity data BEFORE the chunk data, you know, the OPPOSITE of what vanilla does!
// So we can not GARENTEE that the world state is the real state for the block...
// So, once again in the long line of US having to accommodate BUKKIT breaking things,
// here it is, assume that the TE is only 1 cubic block. Problem with this is that it may
// cause the TileEntity renderer to error further down the line! But alas, nothing we can do.
cbb = new net.minecraft.util.math.AxisAlignedBB(pos.add(-1, 0, -1), pos.add(1, 1, 1));
}
if (cbb != null) bb = cbb;
}
return bb;
}
/**
* Checks if this tile entity knows how to render its 'breaking' overlay effect.
* If this returns true, The TileEntitySpecialRenderer will be called again with break progress set.
* @return True to re-render tile with breaking effect.
*/
default boolean canRenderBreaking()
{
Block block = getTileEntity().getBlockState().getBlock();
return (block instanceof net.minecraft.block.BlockChest ||
block instanceof net.minecraft.block.BlockEnderChest ||
block instanceof net.minecraft.block.BlockSign ||
block instanceof net.minecraft.block.BlockSkull);
}
/**
* If the TileEntitySpecialRenderer associated with this TileEntity can be batched in with another renderers, and won't access the GL state.
* If TileEntity returns true, then TESR should have the same functionality as (and probably extend) the FastTESR class.
*/
default boolean hasFastRenderer()
{
return false;
}
}