User Tools

Site Tools


tutorial:blockentityrenderers

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorial:blockentityrenderers [2019/07/28 07:03] – ↷ Page moved from blockentityrenderers to tutorial:blockentityrenderers fudgetutorial:blockentityrenderers [2019/08/13 12:46] fudge
Line 3: Line 3:
 Make sure you [[tutorial:blockentity|added a block entity]] before reading this tutorial!  Make sure you [[tutorial:blockentity|added a block entity]] before reading this tutorial! 
 ===== Introduction ===== ===== Introduction =====
-Some may say blocks by themselves aren't that interesting, +Blocks by themselves aren't that interesting, 
 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 26: Line 26:
 @Override @Override
 public void onInitialize() { public void onInitialize() {
-    ...+    [...]
     BlockEntityRendererRegistry.INSTANCE.register(DemoBlockEntity.class, new MyBlockEntityRenderer());     BlockEntityRendererRegistry.INSTANCE.register(DemoBlockEntity.class, new MyBlockEntityRenderer());
 } }
Line 48: Line 48:
 <code java> <code java>
     public void render(DemoBlockEntity blockEntity, double x, double y, double z, float partialTicks, int destroyStage) {     public void render(DemoBlockEntity blockEntity, double x, double y, double z, float partialTicks, int destroyStage) {
-       ...+        [...]
         // 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 64:
 <code java> <code java>
     public void render(DemoBlockEntity blockEntity, double x, double y, double z, float partialTicks, int destroyStage) {     public void render(DemoBlockEntity blockEntity, double x, double y, double z, float partialTicks, int destroyStage) {
-        ...+        [...]
         MinecraftClient.getInstance().getItemRenderer().renderItem(stack, ModelTransformation.Type.GROUND);         MinecraftClient.getInstance().getItemRenderer().renderItem(stack, ModelTransformation.Type.GROUND);
  
Line 83: Line 83:
     @Override     @Override
     public void render(DemoBlockEntity blockEntity, double x, double y, double z, float partialTicks, int destroyStage) {     public void render(DemoBlockEntity blockEntity, double x, double y, double z, float partialTicks, int destroyStage) {
-        ...+        [...]
                  
         // Put this right above "MinecraftClient.getInstance().getItemRenderer().renderItem(stack, ModelTransformation.Type.GROUND);"         // Put this right above "MinecraftClient.getInstance().getItemRenderer().renderItem(stack, ModelTransformation.Type.GROUND);"
Line 89: Line 89:
         GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, (float) (light & 0xFFFF), (float) ((light >> 16) & 0xFFFF));         GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, (float) (light & 0xFFFF), (float) ((light >> 16) & 0xFFFF));
                  
-        ...+        [...]
     }     }
 </code> </code>
  
 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