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 [2021/05/20 11:23] – the renderer of DemoBlockEntity should be DemoBlockEntity Renderer instead of MyBlockEntityRenderer solidblock | tutorial:blockentityrenderers [2022/02/07 07:32] – solidblock | ||
---|---|---|---|
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 extends BlockEntityRenderer< | + | public class DemoBlockEntityRenderer<T extends |
// 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 77: | Line 75: | ||
// Rotate the item | // Rotate the item | ||
- | matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion((blockEntity.getWorld().getTime() + tickDelta) * 4)); | + | matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion((blockEntity.getWorld().getTime() + tickDelta) * 4)); |
} | } | ||
</ | </ | ||
Line 84: | Line 82: | ||
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 99: | ||
| | ||
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 106: | ||
The jukebox should now have the proper lighting. | The jukebox should now have the proper lighting. | ||
+ | |||
+ | ===== 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 ''/ |
tutorial/blockentityrenderers.txt · Last modified: 2023/02/09 13:14 by mschae23