I looked at how a filled map item gets block colors, tried something similar, but I've ran into a couple of issues.
My code:
private MaterialColor getBlockColorAt(int x, int z) {
Chunk chunk = client.world.getChunkAt(new BlockPos(x, 0, z));
int y = chunk.getTopBlockY(Heightmap.Type.WORLD_SURFACE, x, z);
BlockPos pos = new BlockPos(x, y, z);
return client.world.getBlockState(pos).getMaterialColor(client.world.getBlockReader(chunk.getPos().x, chunk.getPos().z), pos);
}
Issues: BlockState#getMaterialColor is deprecated and I can't find any alternatives to use
y always returns -1
What am I doing wrong? What do I need to do to get a block's color at a specific position?