tutorial:blockentityrenderers
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:blockentityrenderers [2021/05/20 11:23] – the renderer of DemoBlockEntity should be DemoBlockEntity Renderer instead of MyBlockEntityRenderer solidblock | tutorial: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 '' | The first thing we need to do is create our '' | ||
<code java> | <code java> | ||
- | public class DemoBlockEntityRenderer | + | @Environment(EnvType.CLIENT) |
+ | public class DemoBlockEntityRenderer | ||
// A jukebox itemstack | // A jukebox itemstack | ||
private static ItemStack stack = new ItemStack(Items.JUKEBOX, | private static ItemStack stack = new ItemStack(Items.JUKEBOX, | ||
| | ||
- | public DemoBlockEntityRenderer(BlockEntityRenderDispatcher dispatcher) { | + | public DemoBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) {} |
- | super(dispatcher); | + | |
- | | + | |
- | + | ||
@Override | @Override | ||
public void render(DemoBlockEntity blockEntity, | public void render(DemoBlockEntity blockEntity, | ||
Line 28: | Line 27: | ||
Create a new class next to your main class that implements '' | Create a new class next to your main class that implements '' | ||
<code java> | <code java> | ||
+ | @Environment(EnvType.CLIENT) | ||
public class ExampleModClient implements ClientModInitializer { | public class ExampleModClient implements ClientModInitializer { | ||
@Override | @Override | ||
Line 52: | Line 52: | ||
@Override | @Override | ||
public void onInitializeClient() { | public void onInitializeClient() { | ||
- | BlockEntityRendererRegistry.INSTANCE.register(DEMO_BLOCK_ENTITY, | + | BlockEntityRendererRegistry.register(DEMO_BLOCK_ENTITY, |
} | } | ||
</ | </ | ||
Line 77: | Line 77: | ||
// Rotate the item | // Rotate the item | ||
- | matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion((blockEntity.getWorld().getTime() + tickDelta) * 4)); | + | matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((blockEntity.getWorld().getTime() + tickDelta) * 4)); |
} | } | ||
</ | </ | ||
Line 84: | Line 84: | ||
public void render(DemoBlockEntity blockEntity, | public void render(DemoBlockEntity blockEntity, | ||
[...] | [...] | ||
- | MinecraftClient.getInstance().getItemRenderer().renderItem(stack, | + | MinecraftClient.getInstance().getItemRenderer().renderItem(stack, |
// Mandatory call after GL calls | // Mandatory call after GL calls | ||
Line 101: | Line 101: | ||
| | ||
int lightAbove = WorldRenderer.getLightmapCoordinates(blockEntity.getWorld(), | int lightAbove = WorldRenderer.getLightmapCoordinates(blockEntity.getWorld(), | ||
- | MinecraftClient.getInstance().getItemRenderer().renderItem(stack, | + | MinecraftClient.getInstance().getItemRenderer().renderItem(stack, |
| | ||
[...] | [...] | ||
Line 108: | Line 108: | ||
The jukebox should now have the proper lighting. | The jukebox should now have the proper lighting. | ||
+ | |||
+ | ===== Rendering according to block entity data ===== | ||
+ | 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 ''/ |
tutorial/blockentityrenderers.1621509796.txt.gz · Last modified: 2021/05/20 11:23 by solidblock