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
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
421f559
Create tesr.md
elifoster a979517
add tesr
elifoster dbeaea3
Expand parameters a bit
elifoster bebb987
Fix x, y, z params desc
elifoster 1c322aa
Add info about FastTESR and some other improvements
diesieben07 0bd1eb4
add note about hasFastRenderer
diesieben07 571698f
Merge pull request #1 from diesieben07/tesr
elifoster 8ccec5f
Fix last sentence comma splice
elifoster File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
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. | ||
|
||
#### Parameters | ||
* `tileentity`: This is the instanceof the tile entity being rendered. It uses the generic argument, so, if the class is being inherited correctly, it will not need to be cast to your tile entity class. | ||
* `x`, `y`, `z`: The coordinates of the tile entity as doubles. They are at the origin of the block. | ||
* `partialTicks`: The amount of times, in fractions of a tick, that have passed since the last full tick. | ||
* `destroyStage`: The destroy stage for the block if it is being broken. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is true, TESR's aren't passed world coords.
In
TileEntityRendererDispatcher.renderTileEntity(TileEntity, float, int)
:this.renderTileEntityAt(tileentityIn, (double)blockpos.getX() - staticPlayerX, (double)blockpos.getY() - staticPlayerY, (double)blockpos.getZ() - staticPlayerZ, partialTicks, destroyStage);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. You can get the world coords from the te which is probably what I confused myself with when reading my TESRs.
How should I word that then? The position of the tile entity relative to the player's view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The coordinates at which the TESR should render it's model" or something like that.