Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic information on TESRs #93

Merged
merged 8 commits into from Apr 10, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/tileentities/tesr.md
@@ -0,0 +1,20 @@
TileEntitySpecialRenderer
=========================

A `TileEntitySpecialRenderer` (TESR) is used for handling additional rendering behavior for tile entities. OpenGL (via `GlStateManager`) is used to handle rendering in a TESR. See the OpenGL documentation to learn more.

Creating a TESR
---------------

To create a TESR, create a class that inherits from `TileEntitySpecialRenderer`. It takes a generic argument, of which the object must inherit from `TileEntity`. The generic argument is used in the TESR's method, `renderTileEntityAt`.

Only one TESR exists for a given tile entity. Therefore, values that are specific to a single instance in the world should be stored in the tile entity being passed to the renderer rather than in the TESR itself. For example, an integer that increments every frame, if stored in the TESR, will increment every frame for every tile entity of this type in the world.

### `renderTileEntityAt`

This method is called every frame in order to render the tile entity. It passes the instance of the tile entity being renderered, its coordinates as doubles at the origin of the block, partialTicks<!-- I'm not actually sure what this is used for. -->, and the destroy stage of the block if being destroyed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partialTicks is the amount of time, measured in fractions of a tick, that have passed since the last full tick. It's used for interpolating animated/moving things between ticks, so they don't look really jittery.


Registering a TESR
------------------

In order to register a TESR, call `ClientRegistry#bindTileEntitySpecialRenderer` passing the tile entity class to be renderer with this TESR and the instance of the TESR to use to render all TEs of this class.
2 changes: 2 additions & 0 deletions mkdocs.yml
Expand Up @@ -16,6 +16,8 @@ pages:
- Intro to Blockstates: 'blockstates/states.md'
- Intro to Blockstate JSONs: 'blockstates/introduction.md'
- Forge Blockstate JSON: 'blockstates/forgeBlockstates.md'
- Tile Entities:
- Special Renderer: 'tileentities/tesr.md'
- Items:
- Home: 'items/items.md'
- Events:
Expand Down