Better documentation for IForgeWorldType, TERFast, TERAnimation

Also rename AnimationTESR to TileEntityRendererAnimation
This commit is contained in:
tterrag 2018-12-29 12:18:10 -05:00
parent 7f5a57f4af
commit 0b26047ea8
3 changed files with 43 additions and 16 deletions

View File

@ -24,6 +24,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorldReader;
@ -31,7 +32,6 @@ import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.animation.Event;
import net.minecraftforge.common.animation.IEventHandler;
import net.minecraftforge.common.capabilities.OptionalCapabilityInstance;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.animation.CapabilityAnimation;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import net.minecraftforge.common.property.IExtendedBlockState;
@ -39,18 +39,16 @@ import net.minecraftforge.common.property.Properties;
import java.util.Random;
import org.apache.commons.lang3.tuple.Pair;
/**
* Generic TileEntitySpecialRenderer that works with the Forge model system and animations.
* Generic {@link TileEntityRenderer} that works with the Forge model system and animations.
*/
public class AnimationTESR<T extends TileEntity> extends TileEntityRendererFast<T> implements IEventHandler<T>
public class TileEntityRendererAnimation<T extends TileEntity> extends TileEntityRendererFast<T> implements IEventHandler<T>
{
protected static BlockRendererDispatcher blockRenderer;
@Override
public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, BufferBuilder renderer)
{
{
OptionalCapabilityInstance<IAnimationStateMachine> cap = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY);
if(!cap.isPresent())
{

View File

@ -29,8 +29,29 @@ import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.tileentity.TileEntity;
/**
* A special case {@link TileEntityRenderer} which can be batched with other
* renderers that are also instances of this class.
* <p>
* Advantages:
* <ul>
* <li>All batched renderers are drawn with a single draw call</li>
* <li>Renderers have their vertices depth sorted for better translucency
* support</li>
* </ul>
* <p>
* Disadvantages:
* <ul>
* <li>OpenGL operations are not permitted</li>
* <li>All renderers must use the same {@link VertexFormat}
* ({@link DefaultVertexFormats#BLOCK})</li>
* </ul>
*
* @param <T> The type of {@link TileEntity} being rendered.
*/
public abstract class TileEntityRendererFast<T extends TileEntity> extends TileEntityRenderer<T>
{
@Override
@ -63,6 +84,11 @@ public abstract class TileEntityRendererFast<T extends TileEntity> extends TileE
RenderHelper.enableStandardItemLighting();
}
/**
* Draw this renderer to the passed {@link BufferBuilder}. <strong>DO
* NOT</strong> draw to any buffers other than the one passed, or use any OpenGL
* operations as they will not be applied when this renderer is batched.
*/
@Override
public abstract void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, BufferBuilder buffer);
}

View File

@ -19,6 +19,7 @@ import net.minecraft.world.gen.layer.GenLayerZoom;
import net.minecraft.world.gen.layer.LayerUtil;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.config.IArrayEntry;
public interface IForgeWorldType
{
@ -81,17 +82,19 @@ public interface IForgeWorldType
}
/**
* Creates the GenLayerBiome used for generating the world with the specified
* ChunkProviderSettings JSON String *IF AND ONLY IF* this WorldType ==
* WorldType.CUSTOMIZED.
* Allows modifying the {@link IAreaFactory} used for this type's biome
* generation.
*
*
* @param worldSeed The world seed
* @param parentLayer The parent layer to feed into any layer you return
* @param chunkSettings The ChunkGeneratorSettings constructed from the custom
* JSON
* @return A GenLayer that will return ints representing the Biomes to be
* generated, see GenLayerBiome
* @param <T> The type of {@link IArea}.
* @param <C> The type of {@link IContextExtended}.
*
* @param parentLayer The parent layer to feed into any layer you return
* @param chunkSettings The {@link OverworldGenSettings} used to create the
* {@link GenLayerBiome}.
* @param contextFactory A {@link LongFunction} factory to create contexts of
* the supplied size.
* @return An {@link IAreaFactory} that representing the Biomes to be generated.
* @see {@link GenLayerBiome}
*/
default <T extends IArea, C extends IContextExtended<T>> IAreaFactory<T> getBiomeLayer(IAreaFactory<T> parentLayer,
OverworldGenSettings chunkSettings, LongFunction<C> contextFactory)