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
tutorial:blockentityrenderers [2022/02/07 07:32] solidblocktutorial:blockentityrenderers [2023/02/09 13:14] (current) – "you wants" -> "you want" mschae23
Line 11: Line 11:
 The first thing we need to do is create our ''BlockEntityRenderer'' class: The first thing we need to do is create our ''BlockEntityRenderer'' class:
 <code java> <code java>
-public class DemoBlockEntityRenderer<T extends BlockEntity> implements BlockEntityRenderer<T> {+@Environment(EnvType.CLIENT) 
 +public class DemoBlockEntityRenderer implements BlockEntityRenderer<DemoBlockEntity > {
     // A jukebox itemstack     // A jukebox itemstack
     private static ItemStack stack = new ItemStack(Items.JUKEBOX, 1);     private static ItemStack stack = new ItemStack(Items.JUKEBOX, 1);
Line 26: Line 27:
 Create a new class next to your main class that implements ''ClientModInitializer'' (in this tutorial assume that ExampleModClient is in the same folder as the former ExampleMod is): Create a new class next to your main class that implements ''ClientModInitializer'' (in this tutorial assume that ExampleModClient is in the same folder as the former ExampleMod is):
 <code java> <code java>
 +@Environment(EnvType.CLIENT)
 public class ExampleModClient implements ClientModInitializer { public class ExampleModClient implements ClientModInitializer {
     @Override     @Override
Line 50: Line 52:
 @Override @Override
 public void onInitializeClient() { public void onInitializeClient() {
-    BlockEntityRendererRegistry.INSTANCE.register(DEMO_BLOCK_ENTITY, DemoBlockEntityRenderer::new);+    BlockEntityRendererRegistry.register(DEMO_BLOCK_ENTITY, DemoBlockEntityRenderer::new);
 } }
 </code> </code>
Line 75: Line 77:
  
         // Rotate the item         // Rotate the item
-        matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion((blockEntity.getWorld().getTime() + tickDelta) * 4));+        matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((blockEntity.getWorld().getTime() + tickDelta) * 4));
     }     }
 </code> </code>
Line 108: Line 110:
  
 ===== Rendering according to block entity data ===== ===== Rendering according to block entity data =====
-Sometimes you wants to render according to the block entity data (nbt), and you find they are all empty, even if you can access the data through ''/data get block'' command. That's because you did not sync data from server to client. See [[tutorial:blockentity#Sync data from server to client]].+Sometimes you want to render according to the block entity data (nbt), and you find they are all empty, even if you can access the data through ''/data get block'' command. That's because you did not sync data from server to client. See [[tutorial:blockentity#Sync data from server to client]].
tutorial/blockentityrenderers.1644219126.txt.gz · Last modified: 2022/02/07 07:32 by solidblock