tutorial:blockentityrenderers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:blockentityrenderers [2019/07/28 07:03] – ↷ Page moved from blockentityrenderers to tutorial:blockentityrenderers fudge | tutorial:blockentityrenderers [2019/08/13 15:43] – added more information for client entrypoint fudge | ||
---|---|---|---|
Line 3: | Line 3: | ||
Make sure you [[tutorial: | Make sure you [[tutorial: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Some may say blocks | + | Blocks |
they just stay static at a certain location and a certain size until broken. | they just stay static at a certain location and a certain size until broken. | ||
We can use block entity renderers to render items and blocks associated with a block entity far more dynamically - render multiple different items, | We can use block entity renderers to render items and blocks associated with a block entity far more dynamically - render multiple different items, | ||
Line 22: | Line 22: | ||
} | } | ||
</ | </ | ||
- | And register | + | We're going to need to register our '' |
+ | This wouldn' | ||
+ | However, in a multiplayer setting, where the server runs in a different process than the client, the server code | ||
+ | has no concept of a " | ||
+ | To run initialization code only for the client, we need to setup a '' | ||
+ | |||
+ | Create a new class next to your main class that implements '' | ||
+ | <code java> | ||
+ | public class ExampleModClient implements ClientModInitializer { | ||
+ | @Override | ||
+ | public void onInitializeClient() { | ||
+ | // Here we will put client-only registration code | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Set this class as the '' | ||
+ | <code javascript " | ||
+ | " | ||
+ | [...] | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | And register | ||
<code java> | <code java> | ||
@Override | @Override | ||
- | public void onInitialize() { | + | public void onInitializeClient() { |
- | ... | + | |
BlockEntityRendererRegistry.INSTANCE.register(DemoBlockEntity.class, | BlockEntityRendererRegistry.INSTANCE.register(DemoBlockEntity.class, | ||
} | } | ||
Line 48: | Line 75: | ||
<code java> | <code java> | ||
public void render(DemoBlockEntity blockEntity, | public void render(DemoBlockEntity blockEntity, | ||
- | ... | + | [...] |
// Calculate the current offset in the y value | // Calculate the current offset in the y value | ||
double offset = Math.sin((blockEntity.getWorld().getTime() + partialTicks) / 8.0) / 4.0; | double offset = Math.sin((blockEntity.getWorld().getTime() + partialTicks) / 8.0) / 4.0; | ||
Line 64: | Line 91: | ||
<code java> | <code java> | ||
public void render(DemoBlockEntity blockEntity, | public void render(DemoBlockEntity blockEntity, | ||
- | ... | + | |
MinecraftClient.getInstance().getItemRenderer().renderItem(stack, | MinecraftClient.getInstance().getItemRenderer().renderItem(stack, | ||
Line 83: | Line 110: | ||
@Override | @Override | ||
public void render(DemoBlockEntity blockEntity, | public void render(DemoBlockEntity blockEntity, | ||
- | ... | + | |
| | ||
// Put this right above " | // Put this right above " | ||
Line 89: | Line 116: | ||
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, | GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, | ||
| | ||
- | ... | + | |
} | } | ||
</ | </ | ||
The jukebox should now have the proper lighting. | The jukebox should now have the proper lighting. |
tutorial/blockentityrenderers.txt · Last modified: 2023/02/09 13:14 by mschae23